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 plan skill and feature-dev skill 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 |
solution-architect role |
ARD, API contracts, data models, sequence diagrams, NFR spec |
| Architecture Analysis |
"analyze service X", "document architecture of Y" |
system-architect role |
ARCHITECTURE.md, C4 diagrams, component map, tech debt register |
| Cloud Architecture |
Cloud infra design, landing zones, migration, multi-cloud, networking, cost |
cloud-architect role |
Cloud architecture doc, networking diagrams, cost model, DR plan |
| CI/CD Architecture |
Pipeline design, deployment strategy, GitHub org, platform engineering |
devops-architect role |
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
AGENTS.md (root) — tech stack, project structure, conventions
- Subdirectory
AGENTS.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 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 → solution-architect role
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) — Status, Context (problem + constraints), Decision (selected option + rationale), Consequences (positive/negative/neutral), Alternatives Considered.
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 → system-architect role
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 plan skill:
| Component |
Task |
Complexity |
Role |
| [component] |
[task description] |
S / M / L / XL |
role-id |
- 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: scope summary, deliverables table (document/type/status), key decisions with rationale, risk table (risk/impact/mitigation), and next steps (stakeholder review → plan skill → feature-dev skill).
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
plan skill with the produced ARD and design docs as input
- Architecture Analysis → Share findings with stakeholders. If action items identified — create tickets or run
plan skill for each initiative
- Architecture Evolution → Run
plan skill for each migration phase
Integration
- Input from:
product skill (PRD output), plan skill (architecture questions during planning), direct analysis requests
- Followed by:
plan skill (work decomposition), feature-dev skill (implementation)
- Roles:
solution-architect role (feature design, ADRs, API contracts), system-architect role (system analysis, ARCHITECTURE.md, component boundaries), cloud-architect role (cloud platform design, landing zones, networking, cost), devops-architect role (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-23description: 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---56# Architecture78Produce 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 `plan` skill and `feature-dev` skill for implementation.910## 1. Receive Input and Classify Scope1112Gather the input from the user and classify the type of work:1314- **Accepted inputs**: Feature PRD, architecture analysis request, technical initiative brief, verbal description15- Read every provided document thoroughly1617### Scope Classification1819Determine scope type based on the input:2021| Scope Type | Trigger | Primary Role | Deliverables |22|---|---|---|---|23| **Feature Design** | PRD, feature request, new capability | `solution-architect` role | ARD, API contracts, data models, sequence diagrams, NFR spec |24| **Architecture Analysis** | "analyze service X", "document architecture of Y" | `system-architect` role | ARCHITECTURE.md, C4 diagrams, component map, tech debt register |25| **Cloud Architecture** | Cloud infra design, landing zones, migration, multi-cloud, networking, cost | `cloud-architect` role | Cloud architecture doc, networking diagrams, cost model, DR plan |26| **CI/CD Architecture** | Pipeline design, deployment strategy, GitHub org, platform engineering | `devops-architect` role | 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 |2829If the input spans multiple scope types — execute the corresponding sections for each. If ambiguous — ask the user to clarify.3031### Extract Context3233From the input, extract and organize:3435- **Goal**: What architectural problem we are solving (1–2 sentences)36- **Scope boundary**: Which services, modules, or system areas are affected37- **Stakeholders**: Who consumes the deliverables (engineering, product, ops)38- **Constraints**: Timeline, compatibility, regulatory, team capacity39- **Non-goals**: What is explicitly out of scope4041If the input is incomplete — ask before proceeding. Do not assume missing requirements.4243## 2. Understand Current Architecture4445Before designing anything, map the existing state.4647### 2a. Read Architecture Documentation4849Read the following files (if they exist):50511. **`ARCHITECTURE.md`** — system overview, component boundaries, data flow, deployment topology522. **`AGENTS.md`** (root) — tech stack, project structure, conventions533. **Subdirectory `AGENTS.md` files** — per-service/module context544. **Existing ADRs** — `docs/adr/`, `docs/architecture/`, or similar directories555. **API specs** — OpenAPI files, Protobuf definitions, GraphQL schemas5657### 2b. Scan Affected Areas5859If documentation is incomplete or absent:6061```62// turbo63find . -name "ARCHITECTURE.md" -o -name "*.openapi.*" -o -name "*.proto" -o -name "docker-compose*" -o -name "*.tf" | head -3064```6566Map:67- **Service boundaries**: What services/modules exist, their responsibilities68- **Communication patterns**: REST, gRPC, events, shared DB, message queues69- **Data stores**: Databases, caches, queues — types, ownership70- **External integrations**: Third-party APIs, identity providers, payment systems71- **Deployment topology**: How services are deployed, scaled, networked7273### 2c. Build Context Map7475```76## Current Architecture Context7778| Component | Tech Stack | Owner | Relevant to Scope |79|---|---|---|---|80| [service/module] | [lang + framework] | [team/role] | [yes/no — how] |8182## Existing Decisions83- ADR-NNN: [title] — [status] — [relevance to current work]8485## Gaps Identified86- [missing documentation, undocumented decisions, stale diagrams]87```8889## 3. Define Non-Functional Requirements9091**Apply `solution-architect` role.**9293NFRs must be defined before any design work begins. Skip this step only for pure analysis scope.9495<nfr_specification>9697For each relevant category, define concrete targets:9899| 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 |108109Only include categories relevant to the scope. Omit categories that add no signal.110111</nfr_specification>112113Present NFRs to the user for validation before proceeding.114115## 4. Architecture Design116117Route to the appropriate section(s) based on scope type from Step 1.118119### 4a. Feature Design → `solution-architect` role120121For feature-level design (PRD input), produce deliverables in this order:122123**1. Options Analysis** — Propose 2–3 design options with trade-offs:124125```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```134135**2. Architecture Decision Record (ARD/ADR)** — Status, Context (problem + constraints), Decision (selected option + rationale), Consequences (positive/negative/neutral), Alternatives Considered.136137**3. Detailed Design**:138- **C4 diagrams** (Mermaid) — Context and/or Container level showing the feature's impact139- **Sequence diagrams** — for multi-service interactions, async flows140- **API contracts** — new or modified endpoints (OpenAPI fragments or structured tables)141- **Data models** — new entities, schema changes, migration strategy142- **Error handling** — failure modes, retry strategy, degradation behavior143144**4. Security Review**:145- Threat scenarios (3–5 concrete abuse cases)146- Auth/authz design for new endpoints147- Data protection requirements (PII, encryption, access control)148149### 4b. Architecture Analysis → `system-architect` role150151For analysis scope, produce:152153**1. Architecture Assessment**:154- C4 diagrams (Context + Container level) of current state155- Component inventory with responsibilities, tech stack, dependencies156- Data flow diagrams for critical paths157- Integration point map (sync/async, contracts, SLAs)158159**2. Gap Analysis**:160161| Area | Current State | Desired State | Gap | Priority |162|---|---|---|---|---|163| [area] | [what exists] | [what should exist] | [delta] | High/Med/Low |164165**3. Technical Debt Register**:166167| Item | Impact | Effort | Priority | Recommendation |168|---|---|---|---|---|169| [debt item] | High/Med/Low | S/M/L/XL | [rank] | [action] |170171**4. ARCHITECTURE.md Update** — create or update following `templates/architecture.template.md`.172173### 4c. Architecture Evolution → Both Roles174175For migration/evolution initiatives, produce both:176- ADR (from 4a) documenting the migration decision177- ARCHITECTURE.md update (from 4b) showing target state178- **Migration plan**: phased approach (strangler fig, expand-contract, branch by abstraction)179- **Fitness functions**: automated architectural checks to enforce during transition180- **Rollback strategy**: how to revert if migration fails at each phase181182## 5. Quality Gates183184Review all deliverables against the checklist:185186<quality_checklist>187188- [ ] NFRs are concrete (numbers, not "should be fast")189- [ ] Every decision has documented rationale and alternatives190- [ ] Diagrams match the described architecture (no stale diagrams)191- [ ] API contracts are complete (request, response, errors, auth)192- [ ] Data models include migration strategy for schema changes193- [ ] Security review covers OWASP Top 10 (+ LLM Top 10 for AI systems)194- [ ] Backward compatibility is preserved or migration path documented195- [ ] Observability requirements defined (traces, logs, metrics, alerts)196- [ ] No contradictions with existing ADRs or ARCHITECTURE.md197- [ ] Cost impact estimated for infrastructure/service changes198199</quality_checklist>200201If any check fails — fix the deliverable before presenting.202203## 6. Engineering Estimates204205For feature design scope, produce estimates to feed `plan` skill:206207| Component | Task | Complexity | Role |208|---|---|---|---|209| [component] | [task description] | S / M / L / XL | `role-id` |210211- **Critical path**: Longest dependency chain (e.g., DB Migration → Backend API → Frontend → E2E Tests)212- **Parallelization**: Which tasks can run concurrently by different roles213- **Constraints**: Hard dependencies on external teams, services, or decisions214- **Risks**: Dependency/integration risks with mitigations215216Skip this step for pure analysis scope.217218## 7. Present Deliverables219220Compile and present: scope summary, deliverables table (document/type/status), key decisions with rationale, risk table (risk/impact/mitigation), and next steps (stakeholder review → `plan` skill → `feature-dev` skill).221222Wait for user review. The user may request changes, additional analysis, or approve.223224## 8. Persist Artifacts225226After approval, save deliverables to the project:2272281. **ADRs** → `docs/adr/` or `docs/architecture/decisions/` (create dir if missing)2292. **Design docs** → `docs/architecture/` or `docs/design/`2303. **API contracts** → alongside existing API specs or in `docs/api/`2314. **ARCHITECTURE.md** → project root (update existing or create new)232233For each file:234- Use consistent naming: `ADR-NNN-[kebab-case-title].md`, `[feature]-design.md`235- Verify file was created successfully236237If the project has no established `docs/` structure — propose one and confirm with user.238239## 9. Handoff240241Guide the next steps based on scope:242243- **Feature Design** → Run `plan` skill with the produced ARD and design docs as input244- **Architecture Analysis** → Share findings with stakeholders. If action items identified — create tickets or run `plan` skill for each initiative245- **Architecture Evolution** → Run `plan` skill for each migration phase246247## Integration248249- **Input from**: `product` skill (PRD output), `plan` skill (architecture questions during planning), direct analysis requests250- **Followed by**: `plan` skill (work decomposition), `feature-dev` skill (implementation)251- **Roles**: `solution-architect` role (feature design, ADRs, API contracts), `system-architect` role (system analysis, ARCHITECTURE.md, component boundaries), `cloud-architect` role (cloud platform design, landing zones, networking, cost), `devops-architect` role (CI/CD architecture, deployment strategies, platform engineering)252- **Templates**: `templates/architecture.template.md` (ARCHITECTURE.md structure)253- **Skills**: `context-engineering` skill (for AI/agent system architecture)