Screeps Framework Documentation
June 15, 2026 Β· View on GitHub
Build powerful Screeps bots using modular, tested packages.
The Screeps Framework is a collection of high-quality, well-tested packages that handle common bot functionalityβspawning, economy, defense, remote mining, and more. Focus on your bot's strategy while the framework handles implementation details.
π What is the Screeps Framework?
The Screeps Framework is a modular bot development toolkit extracted from a production Screeps bot. It provides:
- 16+ specialized packages for different bot functions
- Production-tested code running on live Screeps servers
- Swarm architecture based on emergent behavior and pheromone coordination
- CPU-efficient implementations with aggressive caching and optimization
- TypeScript-first with full type safety and IDE support
Framework Goal
"A side quest for this bot is to provide a framework for easy bot development."
β AGENTS.md
The framework enables developers to:
- Get started quickly with working bot code
- Focus on strategy instead of implementation details
- Reuse battle-tested components
- Scale efficiently to 100+ rooms with managed CPU budgets
- Learn from examples of advanced bot architecture
π¦ Framework Packages
The framework consists of 16 specialized packages organized by function:
Process Management
- @ralphschuler/screeps-kernel - Process scheduler with CPU budget management and wrap-around queue
- @ralphschuler/screeps-pheromones - Stigmergic coordination system for swarm behavior
Core Infrastructure
- @ralphschuler/screeps-core - Core utilities, logging, and type definitions
- @ralphschuler/screeps-cache - Unified caching system with TTL and LRU eviction
- @ralphschuler/screeps-memory - Memory schemas and persistence
Economy & Resources
- screeps-spawn - Spawning and body part optimization
- screeps-economy - Resource management, links, terminals, factories
- screeps-chemistry - Lab automation and reaction chains
- @ralphschuler/screeps-remote-mining - Remote mining automation
Combat & Defense
- screeps-defense - Tower automation and threat assessment
Roles & Behavior
- @ralphschuler/screeps-roles - Complete creep role implementations with behavior trees
- screeps-roles - Task management and assignment system
Architecture & Coordination
- @ralphschuler/screeps-empire - Empire-level coordination across shards
- @ralphschuler/screeps-clusters - Colony clustering and coordination
- @ralphschuler/screeps-intershard - Inter-shard communication and coordination
Utilities & Visualization
- @ralphschuler/screeps-pathfinding - Advanced pathfinding with caching
- @ralphschuler/screeps-layouts - Room layouts and blueprints
- @ralphschuler/screeps-visuals - Visualization and debugging
- @ralphschuler/screeps-console - Console command system
- @ralphschuler/screeps-stats - Statistics collection and monitoring
- @ralphschuler/screeps-standards - SS2 Terminal Communications protocol
π― Key Features
1. Modular & Composable
Each package has a single, well-defined responsibility and can be used independently or together:
// Use just spawning
import { SpawnManager } from '@ralphschuler/screeps-spawn';
// Or combine multiple packages
import { Kernel } from '@ralphschuler/screeps-kernel';
import { SpawnManager } from '@ralphschuler/screeps-spawn';
import { linkManager } from 'screeps-economy';
2. Production-Tested
All packages are extracted from a live bot that has:
- Managed 100+ rooms across multiple shards
- Handled complex multi-room logistics
- Defended against player attacks
- Optimized CPU usage under heavy load
3. Swarm Architecture
Based on the five-layer swarm architecture (see ROADMAP.md):
- Empire Layer - Multi-shard coordination
- Shard Layer - Per-shard strategic decisions
- Cluster Layer - Colony groups and inter-room logistics
- Room Layer - Local economy, defense, and construction
- Creep Layer - Individual agent behavior
4. Pheromone-Based Coordination
Uses stigmergic communication where creeps and systems communicate through simple numerical signals (pheromones) in room memory:
- Reduces memory complexity
- Enables emergent behavior
- Scales efficiently to hundreds of rooms
5. CPU-Efficient
Aggressive optimization keeps CPU usage low:
- Unified caching system with TTL and LRU eviction
- CPU budgets enforced by kernel
- Lazy evaluation and periodic updates
- Bucket-aware behavior (high bucket = more analysis, low bucket = core logic only)
Target CPU budgets (per room per tick):
- Economic room: β€ 0.1 CPU
- Combat room: β€ 0.25 CPU
- Empire/global coordination: β€ 1 CPU every 20-50 ticks
π Quick Start
1. Install Framework Packages
# Essential packages for a basic bot
npm install @ralphschuler/screeps-kernel
npm install @ralphschuler/screeps-spawn
npm install screeps-economy
2. Create Your Bot
// src/main.ts
import { Kernel } from '@ralphschuler/screeps-kernel';
import { SpawnManager } from '@ralphschuler/screeps-spawn';
import { linkManager } from 'screeps-economy';
const kernel = new Kernel({ cpuBudget: 10 });
const spawnManager = new SpawnManager();
// Register spawn process
kernel.registerProcess({
id: 'spawning',
priority: 90,
execute: () => {
for (const room of Object.values(Game.rooms)) {
if (!room.controller?.my) continue;
const spawns = room.find(FIND_MY_SPAWNS);
const requests = buildSpawnRequests(room);
spawnManager.processSpawnQueue(spawns, requests);
}
},
cpuBudget: 0.5
});
// Main loop
export function loop() {
kernel.run();
}
3. Run Your Bot
Build and deploy using your preferred method. See the Quick Start Guide for detailed instructions.
π Documentation
Getting Started
- Quick Start Guide - Get running in 10 minutes
- Installation Guide - Setup and configuration
- Architecture Overview - System design and patterns
- Core Concepts - Pheromones, Kernel, Memory
- Performance Guide - CPU optimization and profiling
Package Documentation
Each package has comprehensive documentation:
- API Reference - Full TypeScript API documentation
- Usage Examples - Working code samples
- Integration Patterns - How to combine packages
- Performance - CPU characteristics and optimization
See Package Index for all packages.
Advanced Topics
- Custom Processes - Extend the kernel
- Blueprint Development - Create room layouts
- Multi-Shard Coordination - Cross-shard strategies
- Debugging & Profiling - Performance analysis
Contributing
- Package Development - Create new packages
- Testing Guide - Testing requirements
- Release Process - Publishing packages
ποΈ Architecture Principles
The framework follows these design principles (from ROADMAP.md):
1. Decentralization
Each room has local control logic. Global layers only provide high-level goals ("Shard X: expansion", "Cluster Y: war").
2. Stigmergic Communication
Communication via simple numerical pheromones in Room.memory, not complex object trees. Reduces memory size and parsing costs.
3. Event-Driven Logic
- Critical events (hostiles, nukes, destroyed structures) update flags immediately
- Periodic routines (scans, pheromone updates, market analysis) run every N ticks
4. Aggressive Caching
Paths, scans, and analyses are cached with TTL (in global object, not Memory) and recomputed only when needed.
5. Strict Tick Budget
Target CPU budgets:
- Economic room: β€ 0.1 CPU/tick
- Combat room: β€ 0.25 CPU/tick
- Global coordination: β€ 1 CPU every 20-50 ticks
6. Bucket-Aware Behavior
- High bucket: Enable expensive operations (routing, layout planning)
- Low bucket: Core logic only, throttle logs
π Framework Integration Patterns
Pattern 1: Direct Integration
Call managers directly from your main loop:
spawnManager.processSpawnQueue(spawns, requests);
linkManager.run(room);
Pattern 2: Process-Based
Register with kernel for CPU-budgeted execution:
kernel.registerProcess({
id: 'economy:links',
execute: () => linkManager.run(room),
cpuBudget: 0.1
});
Pattern 3: Task-board driven
Use the roles task board for persistent creep assignments:
import { taskBoard } from '@ralphschuler/screeps-roles';
taskBoard.refreshRoom(room);
const action = taskBoard.getAssignedAction(creepContext);
π Learning Path
Beginner
- Read the Quick Start Guide
- Study examples/minimal-bot
- Understand Core Concepts
- Learn about Spawn Management
Intermediate
- Master Kernel & Processes
- Implement Pheromone Coordination
- Optimize with Caching Strategies
- Build Multi-Room Logistics
Advanced
- Create Custom Processes
- Design Custom Blueprints
- Coordinate Multi-Shard Operations
- Profile and optimize CPU Performance
π€ Contributing
We welcome contributions! See:
- Contributing Guide - How to contribute
- Package Development - Create new packages
- Testing Requirements - Quality standards
π Related Documentation
- ROADMAP.md - Bot architecture and swarm design
- FRAMEWORK.md - Original framework overview
- AGENTS.md - Autonomous development system
- API Documentation - Generated TypeDoc API reference
π License
All framework packages are released under the Unlicense - public domain. Use them however you want!
π Support
- Documentation: This guide and package READMEs
- Examples: See examples/ directory
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Last Updated: 2026-01-27
Framework Version: 0.1.0