Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
362daa9
MCP Integration: Create PRD
Aroton Jul 27, 2026
5120c73
Reference design
Aroton Jul 27, 2026
cfc3eca
MCP Integration: Design Architecture
Aroton Jul 27, 2026
67dea85
MCP Integration: Design Phase 1
Aroton Jul 27, 2026
9ddc263
MCP Integration Phase 1: Contracts, Assets, and Package Scaffold
Aroton Jul 27, 2026
4e343ef
MCP Integration: Design Phase 2
Aroton Jul 27, 2026
8e3144c
MCP Integration Phase 2: Review Evidence and Contract Authority
Aroton Jul 27, 2026
f089022
Archflow: Explore Codebase Context
Aroton Jul 27, 2026
5effa7d
MCP Integration: Design Phase 3
Aroton Jul 27, 2026
a82a66b
MCP Integration Phase 3: MCP Contract Boundary and Dependency Admission
Aroton Jul 27, 2026
682d9c6
Document prototype engineering priorities
Aroton Jul 27, 2026
13a413a
MCP Integration: Design Phase 4
Aroton Jul 27, 2026
5d1a9d7
MCP Integration Phase 4: Guarded MCP Runtime and SDK Compatibility
Aroton Jul 28, 2026
2d86b12
MCP Integration: Design Phase 5
Aroton Jul 28, 2026
c334d2f
MCP Integration Phase 5: Offline Bundle and Release Integrity
Aroton Jul 28, 2026
91a7c95
MCP Integration: Design Phase 6 and Split Phase 7
Aroton Jul 28, 2026
64982a3
Archflow: Explore Codebase Context
Aroton Jul 28, 2026
cd61434
MCP Integration Phase 6: Repository Identity, Paths, and Canonical Di…
Aroton Jul 28, 2026
028e628
MCP Integration: Mark Phase 6 design COMPLETE
Aroton Jul 28, 2026
6c3bdcb
MCP Integration: Design Phase 7 and Split Phase 8
Aroton Jul 28, 2026
d2fb0ac
MCP Integration Phase 7: Durable State and Artifact Schemas
Aroton Jul 29, 2026
3891341
MCP Integration: Mark Phase 7 COMPLETE
Aroton Jul 29, 2026
a449413
MCP Integration Phase 8: Manual Checkpoint Chain and Import
Aroton Jul 29, 2026
7ea7906
MCP Integration: Mark Phase 8 COMPLETE
Aroton Jul 29, 2026
3c47577
docs(archflow): approve phase 9 transaction design
Aroton Jul 29, 2026
ae53831
MCP Integration Phase 9: Transaction Substrate and Exact Replay
Aroton Jul 29, 2026
5f854ac
MCP Integration: Mark Phase 9 COMPLETE
Aroton Jul 29, 2026
ae0a404
MCP Integration: Design Phase 10 adoption and recovery
Aroton Jul 29, 2026
ed0862f
MCP Integration Phase 10: Adoption, Reconciliation, and Recovery
Aroton Jul 29, 2026
5a902ef
MCP Integration: Mark Phase 10 COMPLETE
Aroton Jul 29, 2026
8cede1d
MCP Integration: Design Phase 11 snapshots and restore
Aroton Jul 30, 2026
b752c4a
MCP Integration Phase 11: Snapshots, Implementation Manifests, and Re…
Aroton Jul 30, 2026
b7ee38a
MCP Integration: Design Phase 12 durable gates, waivers, and manual d…
Aroton Jul 30, 2026
69e014f
MCP Integration Phase 12: Durable Gates, Waivers, and Manual Decisions
Aroton Jul 30, 2026
1d82721
MCP Integration: Design Phase 13 host identity, sandbox, and CLI disp…
Aroton Jul 30, 2026
272ab99
MCP Integration Phase 13: Host Identity, Sandbox, and CLI Dispatch
Aroton Jul 30, 2026
fccf3fb
MCP Integration Phase 14: Constitution Adjudication and Review Fixed …
Aroton Jul 31, 2026
6601dd5
ArchFlow: Explore Codebase Context
Aroton Jul 31, 2026
cd7553b
MCP Integration Phase 15: Five-Tool MCP Assembly and Offline Local CLI
Aroton Jul 31, 2026
99ad4bf
MCP Integration: Design Phase 16 installer, initialization, and host …
Aroton Jul 31, 2026
8bb9685
MCP Integration Phase 16: Installer, Initialization, and Host Registr…
Aroton Jul 31, 2026
7cb87ac
MCP Integration: Design Phase 17 normal-mode thin phase skills and tr…
Aroton Aug 3, 2026
72023f7
MCP Integration Phase 17: Normal-Mode Thin Phase Skills and Truthful …
Aroton Aug 3, 2026
7bbfdb3
feat: add manual degraded recovery workflow
Aroton Aug 3, 2026
86617a1
MCP Integration: Design Phase 19 legacy upgrade workflow
Aroton Aug 4, 2026
2a791dc
MCP Integration Phase 19: Legacy Upgrade Workflow
Aroton Aug 4, 2026
1666bc8
MCP Integration: Design Phase 20 reliability and security matrices
Aroton Aug 4, 2026
59d60b0
MCP Integration Phase 20: Reliability and Security Matrices
Aroton Aug 4, 2026
41c581b
MCP Integration: Design Phase 21 real-host E2E and review-quality val…
Aroton Aug 4, 2026
cc30081
MCP Integration Phase 21: Real-host validation checkpoint
Aroton Aug 4, 2026
23c1911
MCP Integration Phase 21: Extend installed validation
Aroton Aug 4, 2026
4846f81
MCP Integration Phase 21: Recalibrate Review Quality
Aroton Aug 4, 2026
b93eab1
MCP Integration Phase 21: Close installed validation and record host …
Aroton Aug 4, 2026
2090a4a
MCP Integration Phase 21: Amendment 2 real-host client-info compatibi…
Aroton Aug 5, 2026
cf362fb
Initialize canonical ArchFlow repository assets and host registrations
Aroton Aug 7, 2026
d756c7c
Add testing/validation baseline context for mcp-e2e-test
Aroton Aug 7, 2026
17f9dff
Harden archflow-local payload input: stdin-first, distinct error taxo…
Aroton Aug 7, 2026
8ce52ee
Rename phase-named code artifacts to functional names
Aroton Aug 7, 2026
365043f
Fix fresh-task review projection ENOENT and opaque INTERNAL_ERROR rep…
Aroton Aug 7, 2026
6f4aecd
Make CLI input contracts discoverable before a call fails
Aroton Aug 7, 2026
1be4c30
Make failed dispatch attempts diagnosable and rename state-write voca…
Aroton Aug 7, 2026
7e886b6
Give the sealed counter-review both sides of every comparison it judges
Aroton Aug 10, 2026
97c75ca
Spend the review envelope's byte budget on hand-written change
Aroton Aug 10, 2026
5c5cbbb
Reject arbitrary entry points on the revision-0 initialization write
Aroton Aug 10, 2026
b47b5d7
Advertise only ref-reachable schema subtrees to MCP clients
Aroton Aug 10, 2026
ac55922
Attach prefilled tool request templates to the derived next action
Aroton Aug 10, 2026
1a21cda
Close skill prose gaps around init shape, envelope passes, and empty …
Aroton Aug 10, 2026
bc6e155
Update the temp-bundle smoke pin for the fifty-fifth project error
Aroton Aug 10, 2026
8d8e804
Rebuild the tracked release and rebind the fast-uri risk decision
Aroton Aug 10, 2026
d296c07
Make every status-derived request executable and every digest machine…
Aroton Aug 10, 2026
28c1021
Rebuild the tracked release and rebind the fast-uri risk decision
Aroton Aug 10, 2026
3a28643
Archflow: Explore Codebase Context
Aroton Aug 10, 2026
d8bd240
Act on the PRD-loop caller feedback: reviewer repo access, universal …
Aroton Aug 10, 2026
9bb7248
Rebuild the tracked release and rebind the fast-uri risk decision
Aroton Aug 10, 2026
50a218d
Compose the create-task request through build-request and make it the…
Aroton Aug 10, 2026
dc35f39
Add the maintained caps-named documentation set under docs/
Aroton Aug 10, 2026
8cd21d0
Make archflow-explore produce the maintained docs/ set and retire leg…
Aroton Aug 10, 2026
db56a81
Simplify the review loop: sub-agent self-review, editorial dispositio…
Aroton Aug 11, 2026
bcc198b
Advertise flat MCP input schemas, name rejected fields, and state the…
Aroton Aug 11, 2026
8a20007
Rebuild the tracked release and rebind the fast-uri risk decision
Aroton Aug 11, 2026
eed9df8
Give the review loop convergence pressure and reclaim retired intent …
Aroton Aug 11, 2026
96f4e85
Fold the constitution review into counter-review; the server decides …
Aroton Aug 11, 2026
26bdea0
Retire degraded mode: read-only outage classifier, exit codes, single…
Aroton Aug 11, 2026
ae79472
Split gates.ts along its responsibility seams
Aroton Aug 11, 2026
fbcf787
Adopt the pinned SDK as JSON-RPC authority; retire session.ts
Aroton Aug 11, 2026
565752d
Give every runtime-validated shape a Zod source before the authority …
Aroton Aug 11, 2026
5f2c76d
Add the schema generation pipeline with config as the first generated…
Aroton Aug 11, 2026
ade0339
Regenerate the leaf, durable, gate, and error schemas from their Zod …
Aroton Aug 11, 2026
4bc1c81
Generate mcp-tools.schema.json from the Zod tool contracts
Aroton Aug 11, 2026
ef365a4
Evict Ajv from production; the runtime ships without a schema compiler
Aroton Aug 11, 2026
8d617b2
Sweep the small frictions: rename, dedupe, and name the dense logic
Aroton Aug 11, 2026
27a113c
Fix the audit nits: dead path-class entry, stale comments, keep notes
Aroton Aug 11, 2026
56f4d2c
Stop binding array subject fields with a const Codex now rejects
Aroton Aug 12, 2026
afa8509
Stop manufacturing constitution uncertainty; merge the doubled gate
Aroton Aug 12, 2026
ae25739
Republish the tracked bundle for the constitution-review merge
Aroton Aug 12, 2026
72457b8
Remove dependency approval system
Aroton Aug 12, 2026
e7a63c0
Make counter-review remediation focused
Aroton Aug 12, 2026
247df34
Persist PRD clarification dialogue
Aroton Aug 12, 2026
bd05ad8
refactor: separate durable authority from workflow data
Aroton Aug 12, 2026
d543eb4
refactor: rename work directory to runtime
Aroton Aug 12, 2026
9b11c61
Move workflow state and policy into CLI and MCP
Aroton Aug 12, 2026
ad057d3
Make human gates conversational
Aroton Aug 13, 2026
ce30ed4
Fix approved phase handoffs
Aroton Aug 13, 2026
389a1d8
Restore durable gate archive compatibility
Aroton Aug 13, 2026
66c4c9b
Combine design approval and artifact commit
Aroton Aug 13, 2026
c6d6b9d
Derive constitution review summaries server-side
Aroton Aug 13, 2026
e70edfb
Authenticate implementation review logs correctly
Aroton Aug 13, 2026
ac6919b
Add constitution configuration skill
Aroton Aug 13, 2026
54c9696
Allow constitution edits on task branches
Aroton Aug 13, 2026
42e975a
Harden adjudication output handling
Aroton Aug 13, 2026
b275548
Fix design approval status projection
Aroton Aug 13, 2026
9891e08
Treat active produce edits as expected
Aroton Aug 13, 2026
e42ae85
Review implementations from sealed snapshots
Aroton Aug 14, 2026
5c54a3c
Omit task authority from review snapshots
Aroton Aug 14, 2026
35b5cf0
Use host credentials for reviewer CLIs
Aroton Aug 14, 2026
6637099
Fix in-flight legacy task upgrades
Aroton Aug 14, 2026
fcf98fa
Client interface aduit
Aroton Aug 14, 2026
fcc1266
Add complexity update
Aroton Aug 14, 2026
a907de0
fix: allow design phases to revise parent documents
Aroton Aug 14, 2026
fefd002
docs: define autonomous MCP workflow interface
Aroton Aug 14, 2026
0377113
Add gitignore
Aroton Aug 14, 2026
ee606c0
update global config
Aroton Aug 14, 2026
f6f9bba
Merge main while preserving the MCP workflow rewrite
Aroton Aug 14, 2026
9331032
Fix CI repository identity validation
Aroton Aug 14, 2026
9e75ef5
Remove hosted CI automation
Aroton Aug 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .archflow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/runtime/
32 changes: 32 additions & 0 deletions .archflow/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ArchFlow copies this template to .archflow/config.yaml during repository initialization.
# Task creation copies and byte-pins it at .archflow/tasks/<task>/config.yaml.
# Changing routing after that point requires creating a new task.
schema_version: "1"
roles:
producer:
model: gpt-5.6-sol
effort: high
counter-reviewer:
model: claude-opus-5
effort: medium
adjudicator:
model: claude-opus-5
effort: medium

# Optional. Caps produce re-entries per phase instance before the attempts-exhausted
# gate opens; defaults to 3. This is a thrash backstop, not the primary brake — the
# loop ends when triage accepts nothing, so review convergence is a triage judgment.
# max_attempts: 3

# Codex-producer orientation (replace the active document above with this block):
# schema_version: "1"
# roles:
# producer:
# model: gpt-5.6-sol
# effort: xhigh
# counter-reviewer:
# model: claude-opus-5
# effort: high
# adjudicator:
# model: claude-opus-5
# effort: high
7 changes: 7 additions & 0 deletions .archflow/constitution/00-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
id: explicit-human-authority
version: 1
status: active
review_trigger: Advancement, approval, review-gate, waiver, or commit authority is inferred rather than explicitly recorded by a human for the exact subject.
---
Required human decisions are explicit and bound to the exact artifact or code subject under review. Silence, elapsed time, agent prose, or a model verdict never supplies approval, waives a gate, authorizes a commit, or advances the workflow.
7 changes: 7 additions & 0 deletions .archflow/constitution/10-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
id: approved-design-before-code
version: 1
status: active
review_trigger: Implementation begins before the applicable phase design is approved, or implementation materially departs from approved architecture without updating and re-reviewing its governing plan.
---
Implementation starts only from an approved phase design. The PRD, architecture, and phase design remain truthful as work proceeds; material deviations update the governing documents and re-enter the applicable review boundary before dependent work advances.
10 changes: 10 additions & 0 deletions .archflow/constitution/20-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: task-and-evidence-isolation
version: 1
status: active
review_trigger: A task reads or mutates another task's files, or an approval, waiver, review, or result is used for bytes other than the subject it identifies.
enforced_by:
- task-path-boundary-tests
- subject-digest-validation
---
Tasks are isolated from one another. Durable decisions and evidence identify the exact task and subject bytes they govern; stale, mismatched, cross-task, malformed, or partial evidence fails closed and cannot authorize advancement.
7 changes: 7 additions & 0 deletions .archflow/constitution/30-product.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
id: honest-human-centered-outcomes
version: 1
status: active
review_trigger: A failure, cancellation, unavailable reviewer, uncertain policy result, or missing evidence is represented as success or silently bypassed.
---
ArchFlow reports uncertainty and failure honestly and preserves human control. Automation performs the labor it can, but unavailable capabilities, inconclusive adjudication, missing evidence, and exhausted attempts remain visible non-success states with a safe next action.
5 changes: 5 additions & 0 deletions .archflow/constitution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ArchFlow constitution

Each numbered Markdown file is one repository-wide policy rule. YAML frontmatter carries its stable identity and positive version; the prose body is the normative rule text. Rule IDs are append-only across approved revisions: change content or status only with a higher version, deprecate instead of deleting, and never reactivate a deprecated ID.

Tasks pin these files from an immutable, human-approved policy-base commit. A task branch cannot amend its own governing constitution.
27 changes: 27 additions & 0 deletions .archflow/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
phases:
- id: explore
skill: archflow-explore
pipeline: [produce]
gate: never
optional: true
- id: prd
skill: archflow-prd
pipeline: [produce, counter_review, triage]
gate: always
- id: design
skill: archflow-design
requires: [prd]
pipeline: [produce, counter_review, triage]
gate: always
- id: phase-design
skill: archflow-phase-design
requires: [design]
iterates: per_phase
pipeline: [produce, counter_review, triage]
gate: on_trigger
- id: phase-impl
skill: archflow-phase-impl
requires: [phase-design]
iterates: per_phase
pipeline: [produce, counter_review, triage]
gate: on_trigger
7 changes: 7 additions & 0 deletions .codex/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# >>> archflow managed MCP server >>>
[mcp_servers.archflow]
command = "archflow-mcp"
args = []
startup_timeout_sec = 30
tool_timeout_sec = 3600
# <<< archflow managed MCP server <<<
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Auto detect text files and perform LF normalization
* text=auto

# ArchFlow state is byte-addressed: -text makes blob OIDs independent of core.autocrlf/core.eol,
# and merge=binary keeps conflicts marker-free while diffs stay readable. Git applies the last
# matching rule, so this must stay after * text=auto.
.archflow/** -text merge=binary

# Canonical generated release text is byte-reproducible with LF endings.
dist/*.mjs text eol=lf
dist/archflow-mcp.mjs -whitespace
dist/archflow-local.mjs -whitespace
dist/*.json text eol=lf
dist/legal/*.md text eol=lf

# Retained upstream license texts preserve their exact source bytes.
release/legal/upstream/** -text
release/legal/upstream/** -whitespace
dist/legal/upstream/** -text
dist/legal/upstream/** -whitespace
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.tmp/
coverage/
.vitest/
*.tsbuildinfo
11 changes: 11 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"mcpServers": {
"archflow": {
"type": "stdio",
"command": "archflow-mcp",
"args": [],
"env": {},
"timeout": 3600000
}
}
}
141 changes: 141 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# ArchFlow

A lightweight, human-centered development workflow for Claude Code and Codex.

## Repository Structure

This repo contains one portable Agent Skills source of truth in `skills/`. The installer copies it to each client's skill-discovery directory.

## Skills

The canonical set contains nine portable skills:

| Skill | Purpose |
|---------|---------|
| `/archflow-init` | Initialize repository assets and project-scoped MCP registrations |
| `/archflow-constitution` | Explain and configure repository-owned constitution rules |
| `/archflow-upgrade <legacy-source> <task>` | Stage a legacy task into a distinct canonical task and guide its migration audit |
| `/archflow-explore` | Explore codebase, produce or refresh the maintained `docs/` documentation set |
| `/archflow-prd <task>` | Research + create PRD for a task |
| `/archflow-design <task>` | Design architecture + phases for a task |
| `/archflow-phase-design <task> N` | Design phase N and run its automatic counter-review |
| `/archflow-phase-impl <task> N` | Implement, verify, review, and commit phase N (fresh session) |
| `/archflow-status [task]` | Check status and next action |

In Codex, invoke the same skill names with `$` instead of `/`: `$archflow-init`, `$archflow-constitution`, `$archflow-upgrade`, `$archflow-explore`, `$archflow-prd`, `$archflow-design`, `$archflow-phase-design`, `$archflow-phase-impl`, and `$archflow-status`.

## How It Works

All working files live in `.archflow/`. Tracked in git during development to preserve progress across sessions. Remove before PR.

```
.archflow/
workflow.yaml # Canonical phase graph
constitution/ # Repository-owned policy rules
tasks/
my-feature/
config.yaml # Versioned task configuration
state.json # Durable workflow authority
prd.md # Product requirements
design.md # Technical design + phase plan
phases/
1/
design.md # Phase design
impl-notes.md # Implementation notes
2/
design.md
impl-notes.md
```

## Installation

```bash
./install.sh
```

Installs the shared skills to `~/.claude/skills/` and `~/.agents/skills/` for global availability.

## Documentation

Human-readable system documentation lives in `docs/` using a caps-naming convention: **caps-named files (`OVERVIEW.md`, `COMPLEXITY.md`, `section/FILE.md`) are the maintained documentation set**. The set is produced and refreshed by `/archflow-explore`; each page carries an `**Explored:** <date> · **Commit:** <short-hash> · **Covers:** <paths>` stamp so a refresh can diff since the stamped commit and re-explore only pages whose covered code changed. `docs/validation/` is separate: point-in-time validation evidence and benchmark data (read by `test/real-host/review-benchmark.test.ts`), not kept current by explore. The maintained set:

```
docs/
OVERVIEW.md # whole-system map, glossary
COMPLEXITY.md # per-subsystem simplification audit
PATTERNS.md # code conventions and idioms
DEPENDENCIES.md # dependency surface and toolchain
TESTING.md # test layout and validation matrix
LIMITATIONS.md # honest reliability/security boundaries
workflow/LIFECYCLE.md # phase graph, pipeline, gates, trust boundaries
workflow/SKILLS.md # the nine skills
mcp/SERVER.md # MCP server, four tools, protocol plumbing
mcp/DISPATCH.md # child reviewer dispatch, sandbox, repo views
cli/COMMANDS.md # archflow-local surface, build-request, degraded mode
review/COUNTER-REVIEW.md # dispatch envelopes, pinned context, review flow, constitution review, waivers
contracts/CONTRACTS.md # canonical JSON, digests, trust brands
state/DURABLE-STATE.md # .archflow layout, transactions, state machine, git boundary
```

**Keep these current.** When a change alters behavior these pages describe — a tool, a command, a gate kind, an envelope rule, a state transition, a trust boundary — update the affected caps-named page in the same change. They are written for humans auditing the workflow: plain language, the *why* behind each system, mermaid diagrams; not API references.

## Engineering Priorities

ArchFlow is an open-source prototype. Optimize for a useful, working, maintainable implementation—not hypothetical production, commercial, monetization, or release requirements.

Use this priority order when making tradeoffs:

1. Make the current user workflow work.
2. Choose the simplest design that meets the current requirement.
3. Keep the code readable, maintainable, and easy to change.
4. Add tests and safeguards proportional to the real risk.
5. Pursue exhaustive correctness, generality, or release polish only when the user explicitly asks for it or a demonstrated blocker requires it.

Default guidance:

- Prefer direct code and existing patterns over new abstractions, frameworks, layers, registries, or generalized machinery.
- Do not build for speculative future requirements. Avoid compatibility layers, migration systems, extension points, exhaustive matrices, and release infrastructure until they are actually needed.
- Validate important boundaries and representative failure cases, but do not attempt to prove every theoretical permutation. Tests should buy confidence, not completeness for its own sake.
- Treat licensing proportionally. Respect licenses and obvious attribution obligations, but default to package metadata and ordinary notices. Do not audit every file, build forensic license validators, or create release-grade legal inventories unless distribution makes them necessary, the user requests them, or a concrete legal issue blocks the prototype.
- A documented limitation or TODO is often better than a large subsystem. Prefer a reversible simple decision over an elaborate attempt to eliminate all uncertainty.
- Existing plans are revisable. If a planned phase is disproportionate to prototype goals, propose a simpler scope at the next design/review gate instead of implementing complexity merely because an older document mentions it.
- Before adding substantial complexity, explain the concrete current problem it solves and ask the user when the tradeoff materially expands scope.

Working and maintainable beats perfect. Simplicity does not override the human trust boundaries below, but those boundaries should be implemented with the least machinery that reliably preserves them.

## Design Principles

ArchFlow is written for models that keep improving. Skills must encode *intent and trust boundaries*, not workarounds for model weaknesses — workarounds become ceilings as models get better. When writing or editing any skill, apply this litmus test to every rule: **is it here because the model used to be bad at something, or because the human needs it?** Only the second kind gets "never/must/exact" language.

Hard rules — human trust boundaries, never soften:

- Never commit or pass a review gate without explicit user approval.
- Never write code before phase-design approval.
- The opposite-client counter-review runs automatically before a human gate. There is no optional review at the end of a gate. A significant human revision starts a fresh automatic review cycle; a simple wording or formatting revision may reuse the prior review for one hop but still requires approval of the final bytes.
- All correspondence at a human gate is conversational and human-readable. Explain what needs attention, why it matters, and the available choices in plain language. Keep gate IDs, digests, JSON, internal paths, protocol codes, and other mechanical bindings out of the default response; show them only when the user explicitly asks for diagnostics or audit detail.
- Phase state machine: no doc → DESIGNED → IN PROGRESS → COMPLETE.
- Task isolation: tasks never read each other's files.
- Parent docs (design.md, prd.md) are updated when implementation deviates — the plan must always reflect reality.
- Every completed phase writes an implementation log; durable, task-independent conventions get proposed for the target project's CLAUDE.md (`.archflow/` is deleted before PR, so anything permanent must live outside it).

Everything else is a default, not a rule:

- The session running a skill is the workflow orchestrator, and its context is the workflow's scarcest resource. Conversation, decisions, gates, triage, and synthesis stay in the orchestrator; bulk work (exploration, research, drafting, fresh-context review, implementation chunks) is delegated to sub-agents by default — spawned with complete briefs (they see nothing of the conversation), writing outputs to disk, returning only conclusions. Inline work is the exception for pieces too small to justify a hand-off — never a client preference. Phrase delegation as explicit imperatives ("spawn one agent per X, run in parallel, wait for all"), not availability conditionals ("when subagents are available") — Codex delegates only when told explicitly, and both clients now provide native sub-agents.
- State the intent and let the model choose the procedure: "return only what the next step needs to decide," not word caps; "sized to the task," not fixed counts.
- Numbers (agent counts, phase counts, chunk counts, conversation rounds) are calibration hints — phrase as "typically" or "default," never "must."
- Techniques that compensate for model limits (mandatory research, forced sub-agent delegation, fixed decomposition) must be conditional on the task actually needing them.
- The human gate reviews evidence and exercises judgment; the agent performs all labor it is capable of, including running verification itself.

## Git, digest, and durable-shape conventions

Learned the hard way in this repository; all apply to any future work.

- **Never pass `--literal-pathspecs` to a Git invocation that uses a `:(top,literal)` pathspec.** The flag disables pathspec magic, so the prefix is then matched as a literal filename and the command silently selects nothing — no error, empty output. `:(top,literal)` alone supplies both literal matching and worktree-root anchoring. `check-attr` takes pathnames rather than pathspecs and needs neither.
- **Validate and materialize a caller-owned object once before inspecting it more than once** — `assertPlainJson` then `structuredClone`. An enumerable getter can otherwise return one value to a validation pass and a different value to a hashing pass, which defeats any assert-don't-filter security property. This is how an excluded field reached a request digest that was supposed to reject it.
- **A type reachable from a persisted root must be a `type` alias, never an `interface`.** `CanonicalDocument<T extends PlainJsonValue>` checks `T` through the whole reachable graph, and TypeScript grants implicit index signatures to type aliases only — so an `interface` nested anywhere inside fails with `TS2344: Index signature for type 'string' is missing`. Branded fields, optional properties, and `readonly` arrays are all fine; the declaration *form* is the whole cause, and blaming the branded strings sends the next reader down a dead end. This also intentionally closes declaration merging on those names: a persisted shape must be exactly what its JSON Schema says, and an ambient merge would silently widen it past the schema.
- **When reading a value through `Object.getOwnPropertyDescriptor`, require `enumerable` as well as `value`.** The two tests guard different hazards. Rejecting accessors prevents split observation (above). Rejecting non-enumerable *data* properties — which are stable under repeated reads, so the accessor check does not cover them — prevents a field that is invisible to `JSON.stringify` and `canonicalJsonBytes`, and therefore to any digest derived from them, from being treated as present. `assertPlainJson` already rejects non-enumerable properties inside a value; a shell or slot check that omits the test is weaker than the check applied to its own contents.
- **A disposable human-facing interface must be reconstructible from durable authority and must never be required to resolve authority already authenticated elsewhere.** Losing or corrupting an interface projection may remove convenience, but it must not strand durable state or force a human to author an internal archive.
- **When one published interface is the only renderer for a human action, its template must enumerate every decision shape the resolver accepts.** Include parallel shapes such as waivers and the cancellation escape path; requiring a human to read server source defeats the interface's trust purpose.
- **A CLI command with no input payload must not read stdin.** Parents commonly keep stdin open, so an input-free command that waits for EOF hangs even though it has everything needed to answer. Parse the command first and read stdin only for commands whose contract requires a payload.
- **Name tests, classes, files, scripts, and identifiers for the behavior they cover, never for the workflow phase that produced them** — phase numbers are workflow state, not code structure, and finding the right artifact must not require knowing project history.
- **An advertised MCP tool inputSchema must keep a plain object root — never a root-level `oneOf`/`allOf`/`$ref`.** At least one host flattens a root-level oneOf by dropping every branch it cannot resolve, advertising the tool as a zero-field object; the model then guesses all-string inputs, and an opaque rejection cannot correct the guess. Merge union arms into one object root (union of properties, shared fields required, a description naming the groups) and keep combinators below the root, where hosts preserve them; the server's strict validation stays the authority, and rejections must name the offending fields.
Loading