devthedeveloper.github.io / home / archi
package archi // import "github.com/devthedeveloper/archi"
// index
Index ¶
// overview
Overview ¶
archi init scans the tree, reads the manifests and entry points, and asks one analyst pass to write down what it learned — cached under .archi/. Every design after that is grounded: Markdown briefings with Mermaid diagrams and file-by-file plans against your real modules. Approve a design and archi builds it — with diffs, versioned backups, and a verify-and-repair loop that runs your own toolchain.
Works with Ollama Cloud (default), Anthropic, or any OpenAI-compatible endpoint — OpenRouter, Groq, vLLM, llama.cpp.
// quick start
Quick start ¶
# install
go install github.com/devthedeveloper/archi@latest
# pick a provider (Ollama Cloud is the default)
export OLLAMA_API_KEY=… # or ANTHROPIC_API_KEY / OPENAI_API_KEY
# learn a codebase, then design against it
cd my-service
archi init
archi design "make order processing idempotent"
In a terminal, design runs the full loop: a short interview, a streamed design, then approve & build, modify, or ask questions. Piped or with -no-interactive it prints pure Markdown, so it stays scriptable.
// features
Features ¶
codebase profile
A scan plus one analyst pass produce profile.md and a deterministic file map — the grounding every later call ships with.
freshness fingerprint
A stat-only hash of every file detects drift; init -refresh updates the profile incrementally from only what changed.
design ensemble
Explorer → designer → a critic panel (security, simplicity, grounding) that can send the design back for revision before you ever see it.
build swarm
Big designs are planned into work packets and built in parallel waves, then merged — with arbitration when two packets touch one file.
verify & repair
After applying, archi runs your toolchain (go vet, tests, npm, make) and iterates repairs on failures, up to a bounded loop.
backups & rollback
Every overwrite or delete is copied to a timestamped run under .archi/backups/ first. archi rollback restores any run.
review panel
archi review judges any diff with the critic panel. CI-friendly: exit 0 clean, 1 blocking, 2 operational.
team memory
Built designs distill into .archi/memory/decisions.md — durable, greppable decisions that ground the next design.
secret hygiene
Key-shaped strings are redacted before any file content reaches a prompt; .env, *.pem, and friends never enter the scan.
context budgeting
Grounding is fitted to a token budget (48k default): the profile always ships whole, the map and focus files shrink to fit.
MCP server
archi serve speaks the Model Context Protocol over stdio, so Claude Code, Claude Desktop, and Cursor call archi as tools.
GitHub App
Comment /archi design on an issue, get a design; approve, get a draft PR with generated code; opt in to auto-review on every PR.
// command reference
Command reference ¶
Ten commands. Flags shown are the ones you'll reach for; every command answers -h with the full set.
Scan a repository and cache an understanding in .archi/. Run once per repo; refresh when it drifts.
| flag | default | meaning |
|---|---|---|
-provider | ollama | ollama, anthropic, or openai |
-model | provider default | model id (glm-5.2:cloud, claude-fable-5, gpt-5.2, …) |
-refresh | off | update the cache incrementally from what changed (falls back to a rebuild past 40% drift) |
-force | off | rebuild even if .archi/ exists |
-max-file-kb | 256 | skip files larger than this when sampling |
Design a change against the learned codebase — interview, streamed design, review loop, optional build. The request may be arguments, -f <file>, or stdin.
| flag | default | meaning |
|---|---|---|
-agents | full | full runs the ensemble (explorer + critics); fast is a single call |
-focus | — | glob of files to include as extra grounding (repeatable) |
-build | off | after designing, generate the code (non-interactive) |
-yes | off | auto-approve writing generated files |
-swarm | on with full | split the build into parallel packets |
-verify / -max-repair | on / 3 | run the repo's toolchain after applying; repair iterations |
-rounds | 1 | designer ↔ critic debate rounds (1–3) |
-critic-model | design model | cheaper model for the critic panel |
-o / -html | stdout | write to a file / also render standalone HTML with drawn diagrams |
-max-tokens | 8000 | output budget for the design |
What archi has learned here: provider, language breakdown, cache freshness and age, recent designs, backups, memory.
Review a diff with the critic panel. Source by precedence: -patch, piped stdin, or git diff HEAD. Exit codes are a CI contract:
| exit | meaning | check-run mapping |
|---|---|---|
| 0 | clean, or advisory findings only | success / neutral |
| 1 | blocking findings | failure |
| 2 | operational fault — the tool couldn't run | neutral — never blocks a merge |
Generate a test plan plus test files for a saved design (default: the newest built one). -yes auto-approves writing the files.
Propose README and docs updates from the design history since the last doc run — keeping documentation in sync with what was actually designed and built.
Show, edit, or compact the decision memory. compact merges and shrinks entries, backing up the original first.
Restore the files a build run overwrote — and delete the ones it created — from .archi/backups/. -list shows available runs; the default target is the newest.
Run as an MCP server over stdio for agent clients — documented below.
Print the version.
// integration: agents
MCP server ¶
archi serve speaks JSON-RPC 2.0 over stdin/stdout — the Model Context Protocol stdio transport — so agent clients call archi as tools. Every call is confined to the -root directory, writes are dry-run by default, and a dirty repo refuses real writes unless the caller says allow_dirty:true.
| tool | what it does | safety |
|---|---|---|
archi_status | cache state, freshness, recent designs | read-only |
archi_init | learn or refresh the repo cache | writes only .archi/ |
archi_design | design doc, saved under .archi/designs/ | read-only on your tree |
archi_build | design → file changes with unified diffs | dry run by default; real writes are backed up |
archi_review | critic-panel review of a patch or the working tree | read-only |
archi_rollback | restore a backup run | the tool call is the confirmation |
# Claude Code
claude mcp add archi -- archi serve -root "$(pwd)"
# Claude Desktop / Cursor — .mcp.json
{"mcpServers": {"archi": {"command": "archi", "args": ["serve"],
"env": {"ARCHI_TIMEOUT": "10m"}}}}
stdout is 100% protocol JSON; progress and logging go to stderr. Provider keys come from the server's environment and never cross the wire.
// integration: teams
GitHub App ¶
archi-app — its own zero-dependency module under app/ — is a webhook service that runs the CLI in per-job workspace clones and posts results back to GitHub. Commenters need write access; every accepted command is acked with a 👀 reaction.
| comment | result |
|---|---|
/archi design <request> | the design, posted as a comment |
/archi design --pr <request> | a draft PR with docs/designs/<slug>.md on an archi/design-* branch |
/archi build | on that design PR: generated code, pushed to the same branch |
/archi review | a PR review from the critic panel + an archi review check run |
With auto_review: true in .github/archi.yml, every PR open and synchronize gets a review check automatically. Fork PRs are reviewed from the API diff — fork code is never checked out, and /archi build never runs on forks.
# .github/archi.yml — flat key: value only
provider: anthropic # ollama | anthropic | openai
model: claude-fable-5
critic_model: claude-haiku-4-5
agents: full # full | fast
auto_review: true
max_tokens: 12000
Deploying
One container (Dockerfile included) with git, both binaries, and a volume for the shared .archi cache. Required env: APP_ID, WEBHOOK_SECRET, PRIVATE_KEY_PATH or PRIVATE_KEY_BASE64. Tunables: WORKERS, QUEUE_SIZE, MAX_JOBS_PER_HOUR, JOB_TIMEOUT, CACHE_DIR, WORK_DIR, ARCHI_BIN. Jobs on one repo serialize under a per-repo lock; the cache is keyed by default-branch SHA, so an unchanged repo skips init entirely and a drifted one refreshes incrementally.
// configuration
Configuration ¶
Everything is environment variables — no config files to manage on the CLI side.
| variable | default | meaning |
|---|---|---|
OLLAMA_API_KEY / OLLAMA_HOST | — | Ollama Cloud key, or a local Ollama host |
ANTHROPIC_API_KEY | — | for -provider anthropic |
OPENAI_API_KEY / OPENAI_BASE_URL | — | any OpenAI-compatible endpoint: OpenRouter, Groq, vLLM, llama.cpp… |
ARCHI_TIMEOUT | none | overall per-request cap, e.g. 10m — streaming included |
ARCHI_CONTEXT_TOKENS | 48000 | grounding budget for design (profile + map + focus) |
ARCHI_AGENT_CONCURRENCY | 3 | agent worker-pool size for ensembles and swarms |
ARCHI_RUN_TOKENS | 150000 | output-token budget per run, across all agents |
ARCHI_MEMORY_TOKENS | 4000 | memory's share of the design grounding |
// documents
Documents archi writes ¶
.archi/ ├── profile.md the model's understanding ├── map.md deterministic file map ├── config.json provider, counts, settings ├── fingerprint per-file drift hashes ├── designs/ every design, timestamped │ └── 20260707-…-add-webhooks.md ├── backups/ originals from each build run │ └── 20260707-142317/ + manifest.txt ├── memory/ │ └── decisions.md ADR-ish team memory └── runs/ agent traces, last 20
Everything archi learns or produces is a plain file you can read, grep, and diff — no databases, no lock-in:
Designs carry a small front-matter header (request, provider, date, built) above the full Markdown document, so archi status and test-plan can find them and you can commit the good ones.
Backups are one directory per build run with a manifest distinguishing overwritten files (restored on rollback) from created ones (deleted on rollback).
Memory is an append-only Markdown file of dated decisions, deduplicated and budget-fitted into every future design prompt. archi memory compact keeps it tight.
Design PRs from the GitHub App commit the document to docs/designs/ in your repo — the approved design is the artifact the build implements, verbatim.
// releases
Releases ¶
- v1.8GitHub App —
/archicomment commands, draft design PRs, auto-review check runs, per-repo job queue with SHA-keyed cache - v1.7MCP server —
archi serveexposes six tools over stdio for Claude Code, Claude Desktop, and Cursor - v1.6Standing reviewers + memory —
archi reviewCI contract,test-plan,doc, cross-session decision memory - v1.5Build swarm — parallel packet builds with merge arbitration, verify-and-repair loop,
rollback - v1.4Design ensemble — explorer grounding briefs and the security/simplicity/grounding critic panel with revision rounds
- v1.3Agent runtime — orchestrator with bounded concurrency, run budgets, and traces (an invisible refactor)
- v1.2Production hardening — provider retries, OpenAI backend, secret redaction, versioned backups, fingerprint freshness, context budgeting
- v1.1Interactive design — interview, review loop, code generation, HTML export
- v1.0archi — init, design, status: an architect that knows your codebase