A self-building app pipeline (Forge builds Forge)
claude-codeautomationcideployrollbackflutterguardrails
Forge (a Flutter web and Android app at forge.hampton.website) was repurposed in 2026-07 as an experiment: an app whose only feature is asking an AI agent to change the app itself, then approving or rolling back the result. The pipeline design and its guardrails are reusable for any "agent edits and ships its own code" setup.
Core flow
Request a feature, watch the agent work (live log), see the diff and build result, then a human approves the deploy or rolls back.
Components
- Agent runner: claude-service on the desktop runs
claude -pin the app's repo (claude-service (ProcrastinAI's webhook runner for headless Claude)). - Builder service: a separate small HTTP service (port 9101, systemd user unit) with endpoints for
state, versions, verify, deploy, rollback and job logs (
/job/{id}?offset=Nfor incremental log polling). Reached from the server through the same autossh reverse tunnel as claude-service; a bearer token is shared between the builder's config and a server-only PHP config file. - Server API proxy: admin-only routes (role checked from the JWT) forward to the builder.
- App UI: a Build screen with verify, deploy, deploy-plus-APK and rollback buttons.
Guardrails
- Blast radius: the agent may edit only the app's repo. The runner, the server API and
deploy.share off-limits (documented in the repo's CLAUDE.md; Edit/Write ofdeploy.shdenied in.claude/settings.json). - Verification gate:
flutter analyze --no-fatal-infos(plainflutter analyzeexits 1 on info-level lints),flutter test, and a successfulflutter build web. Deploy returns 428 unless verify passed for the exact current tree (HEAD plus dirty-file fingerprint). - Rollback = the versioned release directory plus symlink swap (Release-directory deploys with an atomic symlink swap).
- Feature accretion control: new features are self-contained screens registered in one feature registry file that the menu and command palette render from.
- Self-built iterations deploy web only; APK builds stay manual.
Lessons
- Deny rules by command name backfire. Bash deny patterns in the repo's settings blocked
interactive sessions and even the separate API repo's
deploy.shthat merely shared the name. They were removed; restraint came from CLAUDE.md plus the verify gate plus human approval. - A "genesis" reset plan needs a protected release (pruning will delete it) and a new major version on reset (version numbers going backward break the updater and Android versionCode).
- Prove the loop end to end early. The pipeline passed verify, deploy and rollback round trips in testing, yet two months later it had never processed a real code-change request, and a review (post #1675) recommended either running it once or archiving it. Infrastructure that is never exercised is a cost, not an asset.
Gotchas
- Writing PHP over an SSH heredoc mangles
$variables; write locally andscp(Heredoc, stdin and scripted-edit pitfalls). - Config files that Apache's PHP must read need mode 644 (600 broke the builder token file).
See also
- claude-service (ProcrastinAI's webhook runner for headless Claude)
- Release-directory deploys with an atomic symlink swap
- Multi-agent development workflows with Claude Code