name: maintain-project-architecture description: Maintain docs/architecture/ARCHITECTURE.md, SLICES.md, and architecture.json for a repository's product/module architecture and provable code slices. Use when a repo needs architecture docs that explain Swift products, Codex plugins, skills, MCP configs, modules, construction, ownership, evidence, stale claims, and slice inventory without generic diagrams or ungrounded architecture claims.
Maintain Project Architecture
Maintain the repo-local architecture documentation under docs/architecture/.
This skill is related to explain-code-slice, but it owns the durable architecture files. explain-code-slice explains or records one end-to-end path. This skill keeps the repo-wide product/module map and the slice index coherent.
Inputs
- Required:
--project-root <path> - Required:
--run-mode <check-only|apply> - Optional:
--architecture-dir <path>
Workflow
- Resolve the project root and architecture directory.
- Detect Swift package products and targets when
Package.swiftexists:- prefer
swift package dump-packagewhen it succeeds - fall back to conservative
Package.swifttext scanning
- prefer
- Detect Codex plugin repository surfaces when plugin metadata exists:
- treat
.codex-plugin/plugin.jsonmanifests as plugin products - treat
.agents/plugins/marketplace.jsoncatalogs as marketplace products that expose plugin entries - treat
skills/*/SKILL.mdfiles and declared.mcp.jsonfiles as module targets - record only manifest-backed or marketplace-backed relationships
- treat
- Build or refresh
docs/architecture/architecture.jsonwith product, target, relationship, evidence, and slice placeholders. - In
check-only, audit required files, required sections, and stale product or target facts inarchitecture.json. - In
apply, create missing architecture files and refresh generated model facts without inventing symbols, data flows, or ownership claims. - Leave
SLICES.mdpresent even when no provable slices have been recorded yet. - Re-run the same audit and report remaining findings.
Required Files
docs/architecture/ARCHITECTURE.mddocs/architecture/SLICES.mddocs/architecture/architecture.json
Writing Expectations
ARCHITECTURE.mdis descriptive. Put preferences, constraints, and "do not" rules inAGENTS.md, not here.- Use fixed section names so Gale can ask for a specific section without ambiguity.
- Treat Swift Package Manager products and targets as first-class architecture facts when available.
- Treat Codex plugin manifests, plugin marketplaces, skills, and declared MCP configs as first-class architecture facts when available.
- Explain products/modules in terms of what they do, who creates or consumes them, what they own, and what code evidence proves that claim.
- Do not use Mermaid, generic graph diagrams, unlabeled arrows, curved-line diagrams, centered text, or diagram labels that interrupt connector lines.
- Keep visual claims in structured
architecture.jsonuntil a purpose-built viewer can render them with Gale-readable layout. - Every generated claim should have evidence: a file path, manifest entry, symbol, command output, or explicit "unverified" marker.
Visual Grammar
Use references/visual-grammar.md when shaping any generated visual model or future viewer output.
Core rules:
- vertical flow dominates
- left/top start position, never center-first reading
- no center-aligned text
- no unlabeled or ambiguous connectors
- connectors must represent one explicit relationship kind such as
creates,passes,stores,calls,returns,owns, ordepends-on - data models appear before slice steps
- code nodes must include symbol names and file anchors when known
Slices
SLICES.md is always created. It may remain mostly empty until provable flows are discovered.
When the user asks for a new slice explanation, use explain-code-slice for the walkthrough and update docs/architecture/SLICES.md with the slice if the path is provable from code.
Codex Subagent Fit
When the user explicitly requests subagents, or applicable workflow guidance tells the agent to ask and the user grants explicit permission, use them for read-heavy discovery. Good jobs include scanning package manifests, listing products and targets, finding entrypoints, or tracing one candidate slice. Keep writes to ARCHITECTURE.md, SLICES.md, and architecture.json in the main thread so the architecture story stays coherent.
Output Contract
- Return Markdown plus JSON with:
run_contextdetected_modelschema_violationsstale_claimsfixes_appliedpost_fix_statuserrors
- If there are no issues and no errors, output exactly
No findings.
Guardrails
- Never auto-commit, auto-push, or open a PR.
- Never invent products, modules, slices, symbols, data models, or code relationships.
- Never edit files outside the architecture directory.
- Never use generic architecture diagrams as filler.
- Treat stale product or target facts as audit failures.
References
assets/ARCHITECTURE.template.mdassets/SLICES.template.mdreferences/visual-grammar.mdreferences/architecture-json.mdscripts/maintain_project_architecture.py