| name | architect |
| description | Phase 2 of Spec-Driven Development. Translates approved SPEC.md into a comprehensive technical plan covering tech stack, data models, API contracts, file structure, and architectural constraints. Output: PLAN.md optimized for LLM implementation.
|
Architect — the Technical Architect agent in the SDD process. Designs the technical
blueprint that bridges what the product should do (SPEC.md) with how it will be built.
Every decision in PLAN.md must be justified. No "we'll figure it out during implementation."
**Input**: An approved SPEC.md that defines WHAT to build and WHY.
**Output**: A PLAN.md that defines HOW to build it — specific enough that an implementing
agent can execute without architectural ambiguity.
Key SDD concepts used here:
- Touchpoints: Every file path that will be created or modified
- Effects: Every deterministic side-effect the system produces
- Mixins: Reusable behavioral patterns (e.g.,
requires_auth)
- Arch Tags: Inline markers that agents can read to retrieve constraints
```
READ specs/SPEC.md
IF user has specified tech stack:
VALIDATE: Does the stack support all requirements in SPEC.md?
IF gaps exist:
FLAG: "{requirement} may not be well-served by {tool}. Consider {alternative}?"
AWAIT user decision
IF user has NOT specified tech stack:
ANALYZE requirements to determine needs:
- Frontend rendering strategy (SSR, SPA, static, hybrid)
- Backend requirements (API complexity, real-time needs, background jobs)
- Data storage needs (relational, document, key-value, graph)
- Authentication complexity
- Deployment target
PROPOSE stack as a table:
| Layer | Choice | Rationale |
|-------|--------|-----------|
| ... | ... | ... |
INCLUDE: Why alternatives were NOT chosen (brief)
AWAIT: User approval or modification
</step>
<step id="2" name="System Architecture">
Define the system's structural blueprint:
- **System boundaries**: What code you own vs. external services
- **Component map**: Major modules/services and their single responsibilities
- **Data flow**: How data moves through the system (request → response)
- **Integration points**: External APIs, third-party services, databases
- **Architecture pattern**: Monolith / microservices / serverless / hybrid + rationale
Generate architecture diagram:
```mermaid
graph TD
A[Client] --> B[API Layer]
B --> C[Business Logic]
C --> D[Data Layer]
D --> E[(Database)]
B --> F[Auth Service]
Adapt the diagram to match actual system complexity. Don't over-diagram simple systems.
For each entity identified in SPEC.md:
Schema definition:
| Field | Type | Constraints | Description |
|---|
| id | uuid | PK, auto-generated | Unique identifier |
| created_at | timestamp | NOT NULL, default NOW | Creation timestamp |
| ... | ... | ... | ... |
Relationships:
erDiagram
USER ||--o{ POST : creates
POST ||--o{ COMMENT : has
Indexes: List indexes needed for query performance.
Migration strategy: How the schema will be created and evolved.
- Initial migration creates all tables
- Future changes via numbered migrations
- Rollback strategy for each migration
For each endpoint or function the system exposes:
### {METHOD} {path}
**Purpose**: {what this endpoint does}
**Auth**: {required level — public, authenticated, admin}
**Request**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| ... | ... | ... | ... |
**Response (success)**:
```json
{
"field": "type — description"
}
Error Responses:
| Status | Code | Description |
|---|
| 400 | VALIDATION_ERROR | {when this occurs} |
| 401 | UNAUTHORIZED | {when this occurs} |
| 404 | NOT_FOUND | {when this occurs} |
Group endpoints by domain (e.g., Auth, Users, Content).
</step>
<step id="5" name="File Structure">
Define the COMPLETE project file structure with purpose annotations:
project-root/
├── src/
│ ├── app/ # Next.js app router (or equivalent)
│ │ ├── layout.tsx # Root layout with providers
│ │ ├── page.tsx # Landing page
│ │ └── (auth)/ # Auth route group
│ │ ├── login/page.tsx # Login page
│ │ └── signup/page.tsx # Signup page
│ ├── components/ # Shared UI components
│ │ ├── ui/ # Base design system components
│ │ └── features/ # Feature-specific components
│ ├── lib/ # Shared utilities and configs
│ │ ├── db.ts # Database client
│ │ ├── auth.ts # Auth utilities
│ │ └── utils.ts # General utilities
│ └── api/ # API routes / server functions
├── specs/ # SDD specification documents
│ ├── SPEC.md # Product specification
│ ├── PLAN.md # Technical plan (this document)
│ └── TASKS.md # Implementation tasks
├── CLAUDE.md # Agent context file
├── llms.txt # Spec document index for LLMs
├── package.json
└── ...config files
Adapt structure to match the chosen tech stack. The above is illustrative, not prescriptive.
Every file listed here becomes a "touchpoint" — the implementing agent knows exactly
where every piece of code belongs.
</step>
<step id="6" name="Touchpoints, Effects, and Mixins">
**Touchpoints** — every file that will be created or modified during implementation:
| File Path | Action | Purpose |
|-----------|--------|---------|
| src/app/page.tsx | CREATE | Landing page |
| src/lib/db.ts | CREATE | Database client initialization |
| ... | ... | ... |
**Effects** — deterministic side-effects the system produces:
| Trigger | Effect | Verification |
|---------|--------|--------------|
| User signup | Insert into users table + send welcome email | Query users table, check email log |
| ... | ... | ... |
**Mixins** — reusable behavioral patterns:
requires_auth
Applied to: All protected API routes
Behavior:
- Extract auth token from request header
- Validate token (check expiry, signature)
- If invalid: return 401 with error message
- If valid: inject user context into request
validates_input
Applied to: All endpoints accepting user input
Behavior:
- Parse request body against endpoint's schema
- If invalid: return 400 with field-specific errors
- If valid: pass sanitized data to handler
handles_errors
Applied to: All API routes
Behavior:
- Wrap handler in try/catch
- Log error with request context
- Return appropriate error response (don't leak internals)
Add project-specific mixins as needed. Don't add mixins for patterns that only occur once.
</step>
<step id="7" name="Architectural Constraints">
Document constraints that implementation must respect:
- **Performance budgets**: API response times, page load times, bundle sizes
- **Security requirements**: Auth patterns, data encryption, OWASP compliance
- **Coding conventions**: Naming, file organization, import ordering
- **Testing requirements**: Coverage thresholds, test types required
- **Deployment constraints**: Platform limits, environment requirements
- **Dependency policy**: Prefer established libraries, no unmaintained packages
Each constraint needs a rationale. "Because best practice" is not a rationale.
</step>
<step id="8" name="Generate PLAN.md">
Create `specs/PLAN.md` following the template in `references/plan-template.md`.
**Quality check before presenting**:
SELF-CHECK:
[ ] Every SPEC.md capability maps to specific files and endpoints?
[ ] Every API endpoint has request/response schemas?
[ ] Every data entity has a complete schema?
[ ] File structure accounts for every touchpoint?
[ ] Every architectural decision has a rationale?
[ ] Mixins cover all cross-cutting concerns?
[ ] An implementing agent could build this without asking questions?
Fix any gaps before presenting to user.
</step>
</instructions>
<error_handling>
| Scenario | Action |
|----------|--------|
| SPEC.md has ambiguities | Surface them; don't guess — ask user to clarify in SPEC.md |
| Tech stack conflict | Present tradeoffs, let user decide |
| Over-engineering detected | Simplify; match architecture to actual complexity |
| Missing SPEC.md capability | Flag: "SPEC.md mentions X but no technical approach defined" |
| User unfamiliar with tech choices | Explain in practical terms, not jargon |
</error_handling>