architecture
Architecture Design Skill
Trigger
- Keywords: architecture, architecture design, architecture doc, component diagram, 3-architecture, system design, document architecture
When NOT to Use
- Tech spec writing (use
/tech-spec) - Code implementation (use
/feature-dev) - Architecture consulting only (use
/codex-architect) - Implementation roadmap (use
/deep-analyze)
Usage
/architecture # Auto-detect feature, create/update
/architecture <feature-keyword> # Specify feature
/architecture --skip-debate # Skip Phase 3 adversarial debate
Workflow
sequenceDiagram
participant U as User
participant C as Claude
participant E as Explore Agent
participant X as Codex
participant D as Architecture Designer
participant B as /codex-brainstorm
C->>C: Phase 0: Context Resolution
par Phase 1: Research
C->>E: Track A: Code pattern analysis (background)
C->>C: Track B: Read tech-spec (inline)
end
E-->>C: Component list + dependencies
C->>X: Track C: Architecture advice
X-->>C: Independent recommendations
C->>D: Phase 2: Architecture Design
D-->>C: Component + flow + decisions
C->>B: Phase 3: Verification (debate)
B-->>C: Equilibrium conclusion
C->>C: Phase 4: Write 3-architecture.md
C->>U: Auto-trigger /codex-review-doc
Phase 0: Context Resolution
Detect the target feature using the 5-level cascade.
See @skills/tech-spec/references/feature-context-resolution.md for the full algorithm.
node scripts/resolve-feature-cli.js 2>/dev/null || echo '{}'
| State | Mode |
|---|---|
3-architecture.md exists |
Update (incremental) |
3-architecture.md absent + 2-tech-spec.md exists |
Create (tech-spec-informed) |
3-architecture.md absent + no tech-spec |
Create (code-only research) |
| Feature not resolved | Gate: Need Human |
Scope Gate
For small features (tech-spec WBS has only 1 task, or no tech-spec and < 3 related files), suggest keeping architecture in tech-spec Section 3 instead of creating a separate document. Use AskUserQuestion to confirm.
Phase 1: Architecture Research (parallel)
Launch research tracks. Tracks A and B run in parallel; Track C runs after both complete.
Track A: Code Pattern Analysis (background)
Agent({
description: "Analyze architecture patterns for <feature>",
subagent_type: "Explore",
run_in_background: true,
prompt: "Analyze the codebase architecture for feature <key>:
1. Trace execution paths of related modules
2. Map component dependencies (imports, calls)
3. Identify integration points with other features
4. Read docs/architecture.md for global context
Output: component list + dependency graph + integration points"
})
Fallback: subagent_type: "general-purpose" if Explore unavailable.
Track B: Tech-spec Extraction (inline)
If 2-tech-spec.md exists:
- Read Section 3 (Technical Solution) — architecture diagram, data model, API design
- Read Section 4 (Risks) — constraints, dependencies
- Read Section 7 (Open Questions) — unresolved design decisions
If no tech-spec: skip (code-only mode).
Track C: Codex Architecture Advice (after A+B)
mcp__codex__codex({
prompt: <from references/codex-prompt.md>,
sandbox: 'read-only',
'approval-policy': 'never',
})
Provide feature context metadata only — never feed Claude's conclusions (per @rules/codex-invocation.md).
Save threadId for potential follow-up.
Graceful degradation: Codex unavailable → proceed without (warn in output).
Phase 2: Architecture Design
Dispatch architecture-designer agent with merged research results:
Agent({
description: "Design architecture for <feature>",
subagent_type: "architecture-designer",
prompt: `Design the architecture for <feature>.
## Input Context
${TECH_SPEC_SUMMARY}
${CODE_ANALYSIS}
${CODEX_ADVICE}
## Required Output
Follow the output template at @skills/architecture/references/template.md:
1. Component diagram (Mermaid flowchart)
2. Component responsibility table
3. Data flow (Mermaid sequence diagram)
4. Integration points with existing systems
5. Architecture decisions (AD-N: context → options → decision → rationale)
6. Deployment considerations (if applicable)
## Constraints
- Follow @rules/docs-writing.md conventions
- Reference actual code (file:line, not invented)
- Mark assumptions explicitly
- Redact credentials/secrets per @rules/security.md`
})
Fallback: if architecture-designer agent unavailable, use solution-architect agent.
Phase 3: Verification (conditional)
Invoke /codex-brainstorm via Skill tool:
Skill("codex-brainstorm", `Evaluate the proposed architecture for <feature>.
Focus: scalability, maintainability, integration complexity, testability.
Constraints:
- Component diagram from Phase 2
- Tech-spec constraints from Phase 1
- Known risks`)
Must produce: threadId + equilibrium conclusion.
Skip Conditions
| Condition | Action |
|---|---|
--skip-debate flag |
Skip Phase 3 |
| Scope gate triggered (small feature) | Skip Phase 3 |
| Update mode (incremental change) | Skip Phase 3 |
Graceful degradation: /codex-brainstorm timeout → record timeout in Verification section, still output document.
Phase 4: Output
Write docs/features/<key>/3-architecture.md using the output template.
See references/template.md for the full template.
Cross-References
Auto-insert links:
> **Source**: [Tech Spec](./2-tech-spec.md)(if exists)> **Request**: [Request](./requests/YYYY-MM-DD-*.md)(if active request found)
Auto-Trigger
After Write completes, auto-trigger /codex-review-doc per @rules/auto-loop.md.
Arguments
| Argument | Default | Description |
|---|---|---|
<feature-keyword> |
auto-detect | Target feature |
--skip-debate |
false | Skip Phase 3 adversarial debate |
Verification
- Feature context resolved (create/update mode determined)
- Research completed (code + tech-spec + Codex)
- Architecture design includes all required sections
- Mermaid diagrams are valid
- Architecture decisions use AD-N format with rationale
- Cross-references to tech-spec and request docs included
-
/codex-review-docpassed (auto-triggered) - No
git add/commit/pushexecuted
References
references/template.md— Output template for3-architecture.mdreferences/codex-prompt.md— Codex independent architecture research prompt@skills/tech-spec/references/feature-context-resolution.md— 5-level feature detection
Examples
Input: /architecture
Action: Auto-detect feature → research (code + spec + Codex) → design → debate → write 3-architecture.md → /codex-review-doc
Input: /architecture statusline-config
Action: Resolve "statusline-config" → read tech-spec → research code → design → write → review
Input: /architecture --skip-debate
Action: Auto-detect → research → design → skip debate → write → review
More from sd0xdev/sd0x-dev-flow
statusline-config
Customize Claude Code statusline. Use when: user says 'statusline', 'status line', 'customize statusline', 'modify statusline', 'statusline settings', 'statusline theme', 'change theme', 'color scheme', wants to add/remove/change segments (cost, git, model, context), switch color themes (catppuccin, dracula, nord), or asks what can be shown in the statusline.
52tech-spec
Tech spec generation and review. Use when: designing features, writing specs, spec review. Not for: requirements analysis (use req-analyze), implementation (use feature-dev), architecture advice (use codex-architect). Output: numbered tech spec document.
45codex-brainstorm
Adversarial brainstorming via Claude+Codex debate. Use when: exploring solutions, feasibility analysis, exhaustive enumeration. Not for: implementation (use feature-dev), architecture only (use codex-architect). Output: Nash equilibrium consensus + action items.
7security-review
Security review via Codex MCP. Use when: OWASP Top 10 audit, dependency vulnerability check, security-sensitive changes. Not for: code review (use codex-code-review), test review (use test-review). Output: security findings + audit report.
7test-review
Test coverage review via Codex MCP. Use when: reviewing test sufficiency, identifying coverage gaps, test quality audit. Not for: generating tests (use codex-test-gen), code review (use codex-code-review). Output: coverage analysis + gap report.
7post-dev-test
Post-development test completion. Use when: checking test coverage after feature-dev, writing missing integration/e2e tests. Not for: unit test generation (use codex-test-gen), test review (use test-review). Output: test files + coverage report.
6