Architecture
Produce architecture deliverables from a feature PRD, module/service analysis request, or architectural initiative. This workflow creates documentation — no code is written here. Output feeds into /feature-plan and /feature-dev for implementation.
1. Receive Input and Classify Scope
Gather the input from the user and classify the type of work:
- Accepted inputs: Feature PRD, architecture analysis request, technical initiative brief, verbal description
- Read every provided document thoroughly
Scope Classification
Determine scope type based on the input:
| Scope Type |
Trigger |
Primary Role |
Deliverables |
| Feature Design |
PRD, feature request, new capability |
Agent(solution-architect) |
ARD, API contracts, data models, sequence diagrams, NFR spec |
| Architecture Analysis |
"analyze service X", "document architecture of Y" |
Agent(system-architect) |
ARCHITECTURE.md, C4 diagrams, component map, tech debt register |
| Cloud Architecture |
Cloud infra design, landing zones, migration, multi-cloud, networking, cost |
Agent(cloud-architect) |
Cloud architecture doc, networking diagrams, cost model, DR plan |
| CI/CD Architecture |
Pipeline design, deployment strategy, GitHub org, platform engineering |
Agent(devops-architect) |
CI/CD architecture doc, pipeline diagrams, DORA targets, governance |
| Architecture Evolution |
"migrate to X", "redesign Y", tech debt initiative |
Multiple |
ARD + ARCHITECTURE.md updates, migration plan, fitness functions |
If the input spans multiple scope types — execute the corresponding sections for each. If ambiguous — ask the user to clarify.
Extract Context
From the input, extract and organize:
- Goal: What architectural problem we are solving (1–2 sentences)
- Scope boundary: Which services, modules, or system areas are affected
- Stakeholders: Who consumes the deliverables (engineering, product, ops)
- Constraints: Timeline, compatibility, regulatory, team capacity
- Non-goals: What is explicitly out of scope
If the input is incomplete — ask before proceeding. Do not assume missing requirements.
2. Understand Current Architecture
Before designing anything, map the existing state.
2a. Read Architecture Documentation
Read the following files (if they exist):
ARCHITECTURE.md — system overview, component boundaries, data flow, deployment topology
CLAUDE.md (root) — tech stack, project structure, conventions
- Subdirectory
CLAUDE.md files — per-service/module context
- Existing ADRs —
docs/adr/, docs/architecture/, or similar directories
- API specs — OpenAPI files, Protobuf definitions, GraphQL schemas
2b. Scan Affected Areas
If documentation is incomplete or absent:
// turbo
find . -name "ARCHITECTURE.md" -o -name "*.openapi.*" -o -name "*.proto" -o -name "docker-compose*" -o -name "*.tf" | head -30
Map:
- Service boundaries: What services/modules exist, their responsibilities
- Communication patterns: REST, gRPC, events, shared DB, message queues
- Data stores: Databases, caches, queues — types, ownership
- External integrations: Third-party APIs, identity providers, payment systems
- Deployment topology: How services are deployed, scaled, networked
2c. Build Context Map
## Current Architecture Context
| Component | Tech Stack | Owner | Relevant to Scope |
|---|---|---|---|
| [service/module] | [lang + framework] | [team/role] | [yes/no — how] |
## Existing Decisions
- ADR-NNN: [title] — [status] — [relevance to current work]
## Gaps Identified
- [missing documentation, undocumented decisions, stale diagrams]
3. Define Non-Functional Requirements
Apply Agent(solution-architect) role.
NFRs must be defined before any design work begins. Skip this step only for pure analysis scope.
For each relevant category, define concrete targets:
| Category |
Specification |
| Availability |
SLO target (e.g., 99.9%), redundancy, failover strategy |
| Latency |
p50/p95/p99 budgets per endpoint or operation |
| Scalability |
Expected load, scaling strategy (horizontal/vertical), limits |
| Cost |
Per-request/per-operation budgets, infrastructure cost bounds |
| Security |
Auth requirements, data classification, compliance (GDPR, SOC2) |
| Observability |
Tracing, logging, metrics requirements, alerting thresholds |
| Data |
Retention, consistency model (strong/eventual), backup/recovery RPO/RTO |
Only include categories relevant to the scope. Omit categories that add no signal.
Present NFRs to the user for validation before proceeding.
4. Architecture Design
Route to the appropriate section(s) based on scope type from Step 1.
4a. Feature Design → Agent(solution-architect)
For feature-level design (PRD input), produce deliverables in this order:
1. Options Analysis — Propose 2–3 design options with trade-offs:
## Option [N]: [Name]
- **Approach**: [Description]
- **Pros**: [List]
- **Cons**: [List]
- **Risk**: [High/Med/Low] — [why]
- **Effort**: [S/M/L/XL]
- **NFR impact**: [How it affects availability, latency, cost, etc.]
2. Architecture Decision Record (ARD/ADR):
# ADR-NNN: [Title]
## Status
Proposed
## Context
[Problem statement, business drivers, technical constraints]
## Decision
[Selected option with clear rationale]
## Consequences
- **Positive**: [benefits]
- **Negative**: [trade-offs, risks accepted]
- **Neutral**: [side effects]
## Alternatives Considered
[Brief summary of rejected options and why]
3. Detailed Design:
- C4 diagrams (Mermaid) — Context and/or Container level showing the feature's impact
- Sequence diagrams — for multi-service interactions, async flows
- API contracts — new or modified endpoints (OpenAPI fragments or structured tables)
- Data models — new entities, schema changes, migration strategy
- Error handling — failure modes, retry strategy, degradation behavior
4. Security Review:
- Threat scenarios (3–5 concrete abuse cases)
- Auth/authz design for new endpoints
- Data protection requirements (PII, encryption, access control)
4b. Architecture Analysis → Agent(system-architect)
For analysis scope, produce:
1. Architecture Assessment:
- C4 diagrams (Context + Container level) of current state
- Component inventory with responsibilities, tech stack, dependencies
- Data flow diagrams for critical paths
- Integration point map (sync/async, contracts, SLAs)
2. Gap Analysis:
| Area |
Current State |
Desired State |
Gap |
Priority |
| [area] |
[what exists] |
[what should exist] |
[delta] |
High/Med/Low |
3. Technical Debt Register:
| Item |
Impact |
Effort |
Priority |
Recommendation |
| [debt item] |
High/Med/Low |
S/M/L/XL |
[rank] |
[action] |
4. ARCHITECTURE.md Update — create or update following templates/architecture.template.md.
4c. Architecture Evolution → Both Roles
For migration/evolution initiatives, produce both:
- ADR (from 4a) documenting the migration decision
- ARCHITECTURE.md update (from 4b) showing target state
- Migration plan: phased approach (strangler fig, expand-contract, branch by abstraction)
- Fitness functions: automated architectural checks to enforce during transition
- Rollback strategy: how to revert if migration fails at each phase
5. Quality Gates
Review all deliverables against the checklist:
If any check fails — fix the deliverable before presenting.
6. Engineering Estimates
For feature design scope, produce estimates to feed /feature-plan:
| Component |
Task |
Complexity |
Role |
| [component] |
[task description] |
S / M / L / XL |
@role |
- Critical path: Longest dependency chain (e.g., DB Migration → Backend API → Frontend → E2E Tests)
- Parallelization: Which tasks can run concurrently by different roles
- Constraints: Hard dependencies on external teams, services, or decisions
- Risks: Dependency/integration risks with mitigations
Skip this step for pure analysis scope.
7. Present Deliverables
Compile and present all architecture deliverables:
# Architecture Deliverables: [Title]
## Scope
[1–2 sentences — what was designed/analyzed]
## Deliverables Produced
| Document | Type | Status |
|---|---|---|
| ADR-NNN: [title] | Architecture Decision Record | Proposed |
| [Feature] HLD | High-Level Design | Draft |
| API Contract: [endpoint] | OpenAPI spec | Draft |
| ARCHITECTURE.md | System documentation | Updated |
## Key Decisions
1. [Decision]: [rationale in one sentence]
2. [Decision]: [rationale in one sentence]
## Risks
| Risk | Impact | Mitigation |
|---|---|---|
| [risk] | High/Med/Low | [mitigation] |
## Next Steps
- [ ] Stakeholder review and approval
- [ ] Run `/feature-plan` to decompose into work packages
- [ ] Run `/feature-dev` per work package with designated roles
Wait for user review. The user may request changes, additional analysis, or approve.
8. Persist Artifacts
After approval, save deliverables to the project:
- ADRs →
docs/adr/ or docs/architecture/decisions/ (create dir if missing)
- Design docs →
docs/architecture/ or docs/design/
- API contracts → alongside existing API specs or in
docs/api/
- ARCHITECTURE.md → project root (update existing or create new)
For each file:
- Use consistent naming:
ADR-NNN-[kebab-case-title].md, [feature]-design.md
- Verify file was created successfully
If the project has no established docs/ structure — propose one and confirm with user.
9. Handoff
Guide the next steps based on scope:
- Feature Design → Run
/feature-plan with the produced ARD and design docs as input
- Architecture Analysis → Share findings with stakeholders. If action items identified — create tickets or run
/feature-plan for each initiative
- Architecture Evolution → Run
/feature-plan for each migration phase
Integration
- Input from:
/feature-design (PRD output), /feature-plan (architecture questions during planning), direct analysis requests
- Followed by:
/feature-plan (work decomposition), /feature-dev (implementation)
- Roles:
Agent(solution-architect) (feature design, ADRs, API contracts), Agent(system-architect) (system analysis, ARCHITECTURE.md, component boundaries), Agent(cloud-architect) (cloud platform design, landing zones, networking, cost), Agent(devops-architect) (CI/CD architecture, deployment strategies, platform engineering)
- Templates:
templates/architecture.template.md (ARCHITECTURE.md structure)
- Skills:
context-engineering skill (for AI/agent system architecture)
1---2name: architecture-83description: Architecture workflow — produce architectural documentation (ARD, design docs, API contracts, C4 diagrams, ARCHITECTURE.md updates) from a feature PRD, analysis request, or architectural initiative. Routes to solution-architect and system-architect roles based on scope. Input from product managers or direct analysis requests.4---5
6# Architecture
7
8Produce architecture deliverables from a feature PRD, module/service analysis request, or architectural initiative. This workflow creates documentation — no code is written here. Output feeds into `/feature-plan` and `/feature-dev` for implementation.
9
10## 1. Receive Input and Classify Scope
11
12Gather the input from the user and classify the type of work:
13
14- **Accepted inputs**: Feature PRD, architecture analysis request, technical initiative brief, verbal description
15- Read every provided document thoroughly
16
17### Scope Classification
18
19Determine scope type based on the input:
20
21| Scope Type | Trigger | Primary Role | Deliverables |
22|---|---|---|---|
23| **Feature Design** | PRD, feature request, new capability | `Agent(solution-architect)` | ARD, API contracts, data models, sequence diagrams, NFR spec |
24| **Architecture Analysis** | "analyze service X", "document architecture of Y" | `Agent(system-architect)` | ARCHITECTURE.md, C4 diagrams, component map, tech debt register |
25| **Cloud Architecture** | Cloud infra design, landing zones, migration, multi-cloud, networking, cost | `Agent(cloud-architect)` | Cloud architecture doc, networking diagrams, cost model, DR plan |
26| **CI/CD Architecture** | Pipeline design, deployment strategy, GitHub org, platform engineering | `Agent(devops-architect)` | CI/CD architecture doc, pipeline diagrams, DORA targets, governance |
27| **Architecture Evolution** | "migrate to X", "redesign Y", tech debt initiative | Multiple | ARD + ARCHITECTURE.md updates, migration plan, fitness functions |
28
29If the input spans multiple scope types — execute the corresponding sections for each. If ambiguous — ask the user to clarify.
30
31### Extract Context
32
33From the input, extract and organize:
34
35- **Goal**: What architectural problem we are solving (1–2 sentences)
36- **Scope boundary**: Which services, modules, or system areas are affected
37- **Stakeholders**: Who consumes the deliverables (engineering, product, ops)
38- **Constraints**: Timeline, compatibility, regulatory, team capacity
39- **Non-goals**: What is explicitly out of scope
40
41If the input is incomplete — ask before proceeding. Do not assume missing requirements.
42
43## 2. Understand Current Architecture
44
45Before designing anything, map the existing state.
46
47### 2a. Read Architecture Documentation
48
49Read the following files (if they exist):
50
511. **`ARCHITECTURE.md`** — system overview, component boundaries, data flow, deployment topology
522. **`CLAUDE.md`** (root) — tech stack, project structure, conventions
533. **Subdirectory `CLAUDE.md` files** — per-service/module context
544. **Existing ADRs** — `docs/adr/`, `docs/architecture/`, or similar directories
555. **API specs** — OpenAPI files, Protobuf definitions, GraphQL schemas
56
57### 2b. Scan Affected Areas
58
59If documentation is incomplete or absent:
60
61```
62// turbo
63find . -name "ARCHITECTURE.md" -o -name "*.openapi.*" -o -name "*.proto" -o -name "docker-compose*" -o -name "*.tf" | head -30
64```
65
66Map:
67- **Service boundaries**: What services/modules exist, their responsibilities
68- **Communication patterns**: REST, gRPC, events, shared DB, message queues
69- **Data stores**: Databases, caches, queues — types, ownership
70- **External integrations**: Third-party APIs, identity providers, payment systems
71- **Deployment topology**: How services are deployed, scaled, networked
72
73### 2c. Build Context Map
74
75```
76## Current Architecture Context
77
78| Component | Tech Stack | Owner | Relevant to Scope |
79|---|---|---|---|
80| [service/module] | [lang + framework] | [team/role] | [yes/no — how] |
81
82## Existing Decisions
83- ADR-NNN: [title] — [status] — [relevance to current work]
84
85## Gaps Identified
86- [missing documentation, undocumented decisions, stale diagrams]
87```
88
89## 3. Define Non-Functional Requirements
90
91**Apply `Agent(solution-architect)` role.**
92
93NFRs must be defined before any design work begins. Skip this step only for pure analysis scope.
94
95<nfr_specification>
96
97For each relevant category, define concrete targets:
98
99| Category | Specification |
100|---|---|
101| **Availability** | SLO target (e.g., 99.9%), redundancy, failover strategy |
102| **Latency** | p50/p95/p99 budgets per endpoint or operation |
103| **Scalability** | Expected load, scaling strategy (horizontal/vertical), limits |
104| **Cost** | Per-request/per-operation budgets, infrastructure cost bounds |
105| **Security** | Auth requirements, data classification, compliance (GDPR, SOC2) |
106| **Observability** | Tracing, logging, metrics requirements, alerting thresholds |
107| **Data** | Retention, consistency model (strong/eventual), backup/recovery RPO/RTO |
108
109Only include categories relevant to the scope. Omit categories that add no signal.
110
111</nfr_specification>
112
113Present NFRs to the user for validation before proceeding.
114
115## 4. Architecture Design
116
117Route to the appropriate section(s) based on scope type from Step 1.
118
119### 4a. Feature Design → `Agent(solution-architect)`
120
121For feature-level design (PRD input), produce deliverables in this order:
122
123**1. Options Analysis** — Propose 2–3 design options with trade-offs:
124
125```
126## Option [N]: [Name]
127- **Approach**: [Description]
128- **Pros**: [List]
129- **Cons**: [List]
130- **Risk**: [High/Med/Low] — [why]
131- **Effort**: [S/M/L/XL]
132- **NFR impact**: [How it affects availability, latency, cost, etc.]
133```
134
135**2. Architecture Decision Record (ARD/ADR)**:
136
137```
138# ADR-NNN: [Title]
139
140## Status
141Proposed
142
143## Context
144[Problem statement, business drivers, technical constraints]
145
146## Decision
147[Selected option with clear rationale]
148
149## Consequences
150- **Positive**: [benefits]
151- **Negative**: [trade-offs, risks accepted]
152- **Neutral**: [side effects]
153
154## Alternatives Considered
155[Brief summary of rejected options and why]
156```
157
158**3. Detailed Design**:
159- **C4 diagrams** (Mermaid) — Context and/or Container level showing the feature's impact
160- **Sequence diagrams** — for multi-service interactions, async flows
161- **API contracts** — new or modified endpoints (OpenAPI fragments or structured tables)
162- **Data models** — new entities, schema changes, migration strategy
163- **Error handling** — failure modes, retry strategy, degradation behavior
164
165**4. Security Review**:
166- Threat scenarios (3–5 concrete abuse cases)
167- Auth/authz design for new endpoints
168- Data protection requirements (PII, encryption, access control)
169
170### 4b. Architecture Analysis → `Agent(system-architect)`
171
172For analysis scope, produce:
173
174**1. Architecture Assessment**:
175- C4 diagrams (Context + Container level) of current state
176- Component inventory with responsibilities, tech stack, dependencies
177- Data flow diagrams for critical paths
178- Integration point map (sync/async, contracts, SLAs)
179
180**2. Gap Analysis**:
181
182| Area | Current State | Desired State | Gap | Priority |
183|---|---|---|---|---|
184| [area] | [what exists] | [what should exist] | [delta] | High/Med/Low |
185
186**3. Technical Debt Register**:
187
188| Item | Impact | Effort | Priority | Recommendation |
189|---|---|---|---|---|
190| [debt item] | High/Med/Low | S/M/L/XL | [rank] | [action] |
191
192**4. ARCHITECTURE.md Update** — create or update following `templates/architecture.template.md`.
193
194### 4c. Architecture Evolution → Both Roles
195
196For migration/evolution initiatives, produce both:
197- ADR (from 4a) documenting the migration decision
198- ARCHITECTURE.md update (from 4b) showing target state
199- **Migration plan**: phased approach (strangler fig, expand-contract, branch by abstraction)
200- **Fitness functions**: automated architectural checks to enforce during transition
201- **Rollback strategy**: how to revert if migration fails at each phase
202
203## 5. Quality Gates
204
205Review all deliverables against the checklist:
206
207<quality_checklist>
208
209- [ ] NFRs are concrete (numbers, not "should be fast")
210- [ ] Every decision has documented rationale and alternatives
211- [ ] Diagrams match the described architecture (no stale diagrams)
212- [ ] API contracts are complete (request, response, errors, auth)
213- [ ] Data models include migration strategy for schema changes
214- [ ] Security review covers OWASP Top 10 (+ LLM Top 10 for AI systems)
215- [ ] Backward compatibility is preserved or migration path documented
216- [ ] Observability requirements defined (traces, logs, metrics, alerts)
217- [ ] No contradictions with existing ADRs or ARCHITECTURE.md
218- [ ] Cost impact estimated for infrastructure/service changes
219
220</quality_checklist>
221
222If any check fails — fix the deliverable before presenting.
223
224## 6. Engineering Estimates
225
226For feature design scope, produce estimates to feed `/feature-plan`:
227
228| Component | Task | Complexity | Role |
229|---|---|---|---|
230| [component] | [task description] | S / M / L / XL | `@role` |
231
232- **Critical path**: Longest dependency chain (e.g., DB Migration → Backend API → Frontend → E2E Tests)
233- **Parallelization**: Which tasks can run concurrently by different roles
234- **Constraints**: Hard dependencies on external teams, services, or decisions
235- **Risks**: Dependency/integration risks with mitigations
236
237Skip this step for pure analysis scope.
238
239## 7. Present Deliverables
240
241Compile and present all architecture deliverables:
242
243```
244# Architecture Deliverables: [Title]
245
246## Scope
247[1–2 sentences — what was designed/analyzed]
248
249## Deliverables Produced
250| Document | Type | Status |
251|---|---|---|
252| ADR-NNN: [title] | Architecture Decision Record | Proposed |
253| [Feature] HLD | High-Level Design | Draft |
254| API Contract: [endpoint] | OpenAPI spec | Draft |
255| ARCHITECTURE.md | System documentation | Updated |
256
257## Key Decisions
2581. [Decision]: [rationale in one sentence]
2592. [Decision]: [rationale in one sentence]
260
261## Risks
262| Risk | Impact | Mitigation |
263|---|---|---|
264| [risk] | High/Med/Low | [mitigation] |
265
266## Next Steps
267- [ ] Stakeholder review and approval
268- [ ] Run `/feature-plan` to decompose into work packages
269- [ ] Run `/feature-dev` per work package with designated roles
270```
271
272Wait for user review. The user may request changes, additional analysis, or approve.
273
274## 8. Persist Artifacts
275
276After approval, save deliverables to the project:
277
2781. **ADRs** → `docs/adr/` or `docs/architecture/decisions/` (create dir if missing)
2792. **Design docs** → `docs/architecture/` or `docs/design/`
2803. **API contracts** → alongside existing API specs or in `docs/api/`
2814. **ARCHITECTURE.md** → project root (update existing or create new)
282
283For each file:
284- Use consistent naming: `ADR-NNN-[kebab-case-title].md`, `[feature]-design.md`
285- Verify file was created successfully
286
287If the project has no established `docs/` structure — propose one and confirm with user.
288
289## 9. Handoff
290
291Guide the next steps based on scope:
292
293- **Feature Design** → Run `/feature-plan` with the produced ARD and design docs as input
294- **Architecture Analysis** → Share findings with stakeholders. If action items identified — create tickets or run `/feature-plan` for each initiative
295- **Architecture Evolution** → Run `/feature-plan` for each migration phase
296
297## Integration
298
299- **Input from**: `/feature-design` (PRD output), `/feature-plan` (architecture questions during planning), direct analysis requests
300- **Followed by**: `/feature-plan` (work decomposition), `/feature-dev` (implementation)
301- **Roles**: `Agent(solution-architect)` (feature design, ADRs, API contracts), `Agent(system-architect)` (system analysis, ARCHITECTURE.md, component boundaries), `Agent(cloud-architect)` (cloud platform design, landing zones, networking, cost), `Agent(devops-architect)` (CI/CD architecture, deployment strategies, platform engineering)
302- **Templates**: `templates/architecture.template.md` (ARCHITECTURE.md structure)
303- **Skills**: `context-engineering` skill (for AI/agent system architecture)