How autoforgeai/autoforge works
Purpose and Launch Surfaces
AutoForge is a long-running autonomous coding harness: it converts an application specification into a persistent feature backlog, then repeatedly runs Claude-powered coding sessions against a generated project. npm users enter through bin/autoforge.js and lib/cli.js; source users use start.py for terminal operation or start_ui.py for the browser UI. The autonomous agent process begins at autonomous_agent_demo.py.
Agent Session Orchestration
The two-stage lifecycle is implemented around session and orchestration modules:
• Initialization creates project structure, Git state, prompts, and the initial feature set.
• Continuation sessions select and implement pending features, persist outcomes, and resume with a fresh model context.
• Parallel/autonomous coordination and progress handling are centered in agent.py, parallel_orchestrator.py, and progress.py.
Agent access to the Claude SDK/provider configuration is isolated in client.py; prompt selection/loading is in prompts.py.
Persistent Project and Feature Domain
Each generated project owns a SQLite features.db, prompts, progress notes, and generated application files. SQLAlchemy persistence and migrations live in api/database.py and api/migration.py. Dependency-aware backlog ordering is handled by api/dependency_resolver.py; registry.py and autoforge_paths.py provide project discovery/path conventions. This boundary lets sessions be disposable while feature status and Git commits remain durable.
MCP Feature-Control Boundary
Agents manage the backlog through an MCP server rather than directly coupling prompt/tool calls to UI behavior. mcp_server/feature_mcp.py exposes operations such as next-feature selection, bulk creation, skipping, regression selection, completion, and progress statistics. It mediates between agent execution and the SQLite feature model in api/database.py, forming the central control loop: agent requests work → MCP resolves/persists status → orchestrator starts the next session.
Security and Execution Constraints
Generated-project command execution is deliberately constrained. security.py validates an allowlisted command set and project-local filesystem scope; auth.py and rate_limit_utils.py support authentication/provider and rate-limit concerns. The intended runtime is Python 3.11+ plus the installed/authenticated Claude Code CLI; model access can use Anthropic, Vertex AI, or configured compatible providers such as Ollama, GLM, Kimi, and custom endpoints.
FastAPI Control Plane
The web backend is a FastAPI service rooted at server/main.py, with REST routers for projects, agents, features, filesystem, terminal, dev servers, schedules, settings, and specification workflows under server/routers/. Stateful process/session concerns are separated into services: agent-related database/chat sessions, process and terminal management, dev-server management, scheduler logic, and project configuration in server/services/. server/websocket.py streams agent status, logs, progress, and feature changes to project-scoped clients.
React Monitoring and Operator UI
The separate React/TypeScript frontend starts at ui/src/main.tsx and composes the application in ui/src/App.tsx. It calls the backend through ui/src/lib/api.ts and maintains live project state through ui/src/hooks/useWebSocket.ts. Operator-facing views cover dashboard/progress, Kanban features, dependency graph, assistant/spec/expansion chats, terminals, browser/dev-server control, logs, schedules, and settings; principal view composition is under ui/src/components/views/.
External Integrations and Delivery
The npm package bootstraps Python environments and launches the local service; Python requirements are split between requirements.txt and requirements-prod.txt. Optional N8N progress webhooks provide external notifications. Local development uses Vite in ui/, while production startup serves the built frontend. CI is defined in .github/workflows/ci.yml.
Main entry points: agent.py Agent coordination · main.py FastAPI app · feature_mcp.py Feature MCP server · App.tsx Operator application
Components 22
Launch Surfaces
- npm launcher · Bootstraps Python and launches the local service.
bin/autoforge.js - Node CLI
lib/cli.js - Terminal start
start.py - Browser UI start
start_ui.py
Agent Runtime
- Autonomous runner
autonomous_agent_demo.py - Agent coordination · Runs initialization, continuation, parallel execution, and progress handling.
agent.py - Parallel orchestration
parallel_orchestrator.py - Model client · Isolates Claude SDK and compatible provider configuration.
client.py - Prompt loader
prompts.py
Feature Control
- Feature MCP server · Backlog operations mediate the agent control loop.
mcp_server/feature_mcp.py - Feature persistence · Stores features and applies migrations.
api/database.py - Dependency resolver
api/dependency_resolver.py - Generated project · Contains application files, prompts, progress, Git state, and features.db.
- Execution security · Enforces allowlisted commands and project-local filesystem scope.
security.py
FastAPI Control Plane
- FastAPI app · REST control plane for projects, agents, features, terminal, dev servers, schedules, and settings.
server/main.py - Stateful services · Manages agent chats, processes, terminals, dev servers, scheduling, and project configuration.
server/services/process_manager.py - Project WebSocket · Streams agent status, logs, progress, and feature changes.
server/websocket.py
Operator UI
- React entry
ui/src/main.tsx - Operator application · Provides dashboard, backlog, graph, chats, terminals, logs, schedules, and settings.
ui/src/App.tsx - Backend API client
ui/src/lib/api.ts - Live state hook
ui/src/hooks/useWebSocket.ts
Other components
- Claude-compatible providers · Anthropic, Vertex AI, or configured compatible endpoints.
Connections 24
- npm launcher → Node CLI: invokes
- Node CLI → Browser UI start: launches
- Terminal start → Autonomous runner: starts
- Autonomous runner → Agent coordination: runs
- Agent coordination → Parallel orchestration: coordinates
- Agent coordination → Prompt loader: loads prompts
- Agent coordination → Model client: requests coding session
- Model client → Claude-compatible providers: uses
- Agent coordination → Feature MCP server: requests feature work
- Feature MCP server → Dependency resolver: orders pending work
- Feature MCP server → Feature persistence: reads and updates
- Feature persistence → Generated project: persists features.db
- Agent coordination → Generated project: writes outcomes and commits
- Agent coordination → Execution security: validates execution
- Browser UI start → FastAPI app: starts service
- FastAPI app → Stateful services: delegates stateful work
- Stateful services → Agent coordination: controls sessions
- FastAPI app → Feature persistence: serves feature data
- FastAPI app → Project WebSocket: publishes events
- React entry → Operator application: mounts
- Operator application → Backend API client: uses
- Operator application → Live state hook: uses
- Backend API client → FastAPI app: REST
- Live state hook → Project WebSocket: subscribes