PocketCoder-A1: An Autonomous Agent for Overnight Development with Claude
PocketCoder-A1 is a CLI tool with a web dashboard that autonomously runs development tasks. The agent operates in sessions, saves state, executes code via Claude CLI or API, and then verifies results: pytest, py_compile, file checks. Supports Claude Max, Claude API, and Ollama providers. Install via pip, run on any project with a dashboard at localhost:7331.
Built in pure Python without frameworks: 15 modules, 7086 lines. HTTP server on http.server, JSON via standard module, files via pathlib. External dependencies minimal: playwright for E2E tests, anthropic/ollama optional.
Architecture and Launching Claude CLI
The agent captures a validation baseline before starting, assembles a prompt, launches Claude CLI as a subprocess with real-time NDJSON parsing. Key launch flags:
import os, subprocess
env = os.environ.copy()
env.pop("CLAUDECODE", None)
proc = subprocess.Popen(
["claude", "-p", prompt,
"--dangerously-skip-permissions",
"--no-session-persistence",
"--max-turns", "25",
"--verbose",
"--output-format", "stream-json"],
cwd=str(project_dir),
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
)
| Flag | Purpose |
|------|---------|
| -p prompt | Non-interactive mode |
| --dangerously-skip-permissions | Auto-confirm tool_use |
| --no-session-persistence | No session saving |
| --max-turns 25 | Iteration limit |
| --output-format stream-json | NDJSON stream |
The parser classifies events: tool_use (Read — blue, Bash — purple, thinking — yellow). Rate_limit_event metrics update the dashboard via AJAX every 2–3 seconds.
Three-Level Result Verification
After a session, the agent doesn't stop at "COMPLETED." Verification runs:
- Level 1 (BLOCKING): py_compile all .py files, pytest, file existence, success_criteria from the task. Failed — retry with error injection.
- Level 2 (WARNING): ruff, build, git diff — logged.
- Level 3 (ANTI-LOOP): Baseline bugs before start. Max 5 attempts, otherwise BLOCKED and move to next task.
Errors are injected into the prompt: "VERIFICATION FAILED, attempt 2/5, BLOCKING: tests 2 failed."
Providers and Task Management
| Provider | Mechanism | Requirements |
|----------|-----------|--------------|
| claude-max | CLI subprocess, Stream-JSON, native tools | Claude Max subscription |
| claude-api | Anthropic SDK, agentic loop, 6 tools | API key |
| ollama | Text streaming, no tool calling | Local Ollama |
Tasks are created in three ways:
- CLI:
pca task add. - Quick Add on the dashboard.
- AI Transform: raw text → structured tasks with priorities and criteria.
Statuses: PENDING, IN PROGRESS, DONE, BLOCKED. Drag-and-drop for priorities. Lifecycle: agent picks the next task automatically.
Real-World Case: Adding a Provider to epotos-templates
Project epotos-templates for document processing. Task: clone the repository, add provider switching Ollama → DeepSeek.
- AI Transform turns raw text into 5 tasks with criteria.
- Agent launch: claude-api, live log with THINK/BASH/READ.
- After session — verification, green checkmark on success.
- Auto-transition to next: analyze ollama.ts, ai-client.ts, grep ports.
Progress from 0/5 to 2/5 tasks per session, with detailed tool call logs.
Key Points:
- Autonomous operation: set tasks — leave, return to verified code.
- Three-level verification prevents false positives.
- Real-time dashboard with NDJSON parsing and token metrics.
- Support for multiple providers via a unified pipeline.
- Open source, 7086 lines of pure Python without frameworks.
Installation: pip install pocketcoder-a1, pca init /path/to/project, pca ui. Suitable for mid/senior developers looking to offload LLM subscription with overnight automation.
— Editorial Team
No comments yet.