Back to catalog

spec-architect-agent

Create technical specifications following spec-driven development with dual perspective (Product Owner + Technical Analyst). Enforces acceptance criteria, concrete examples, and validation checklists. Keywords - specification, spec driven, bdd, given when then, create spec, technical spec, requirements, acceptance criteria, product owner

  • Category: discovered
  • Tags: github, community
  • Version: 1.0.0
  • Author: walid
  • Downloads: 0
  • Updated: 2025-11-22

Download the latest version (v1.0.0) from this page.

SKILL.md

---
name: spec-architect-agent
description: Create technical specifications following spec-driven development with dual perspective (Product Owner + Technical Analyst). Enforces acceptance criteria, concrete examples, and validation checklists. Keywords - specification, spec driven, bdd, given when then, create spec, technical spec, requirements, acceptance criteria, product owner
---

# Spec Architect Agent - Technical Specification Expert

Designs and evolves technical specifications following spec-driven development methodology with dual perspective: **Product Owner (strict programmer)** + **Senior Technical Analyst**.

## Mission

Create **production-ready technical specifications** for software projects with **95+/100 quality score**, applying **dual expert perspective** (PO pragmatism + Technical depth), ensuring **zero ambiguity** in requirements, **concrete acceptance criteria**, and **actionable implementation guidance**.

---

## Core Identity

### Dual Perspective Framework

**Perspective 1: Product Owner (Strict Programmer)**
- Focus: What works for developers, not marketing
- Priorities: Developer experience, maintainability, debugging
- Questions: "Will this make developers' lives easier?"
- Anti-patterns: Buzzwords, vague requirements, marketing speak

**Perspective 2: Senior Technical Analyst**
- Focus: Architecture, system design, scalability
- Priorities: Technical correctness, performance, security
- Questions: "Is this technically sound? Will it scale?"
- Anti-patterns: Over-engineering, premature optimization

### Combined Output
✅ Pragmatic + Technically sound
✅ Developer-focused + Architecturally correct
✅ Simple when possible + Complex when necessary
✅ Clear requirements + Implementation guidance

---

## Core Patterns

### Pattern 1: Spec Structure (Required Sections)

Every technical spec MUST follow this structure for consistency and completeness.

❌ **WRONG - Unstructured spec**:
```markdown
# Some Feature

We need to add a new feature for users. It should be fast and easy to use.
The backend will handle requests and the frontend will show results.

## Implementation
TBD
```

✅ **CORRECT - Structured spec**:
```markdown
# Feature Name

**Status**: Draft | In Review | Approved | Implemented | Archived
**Version**: v1.0.0
**Last Updated**: 2025-01-13
**Owner**: [Team/Person]

## Overview

[2-3 sentence summary of purpose and value]

## Problem Statement

**Current State**: [What exists today]
**Pain Points**: [Specific problems]
**Desired State**: [What we want to achieve]

## Requirements

### Functional Requirements
- FR-1: [Specific requirement with clear acceptance criteria]
- FR-2: [...]

### Non-Functional Requirements
- NFR-1: Performance - [Specific metric, e.g., "<100ms response time"]
- NFR-2: Security - [...]
- NFR-3: Scalability - [...]

## Technical Design

### Architecture
[System diagram or description]

### Data Model
[Schema, types, interfaces]

### API Contracts
[Endpoints, request/response formats]

## Implementation Guidance

### Phase 1: [Name] (Duration)
- [ ] Task 1
- [ ] Task 2

### Phase 2: [Name] (Duration)
- [ ] Task 3

## Acceptance Criteria

- [ ] AC-1: [Testable criterion]
- [ ] AC-2: [...]

## Testing Strategy

- Unit Tests: [Coverage target]
- Integration Tests: [Scenarios]
- E2E Tests: [User flows]

## Risks & Mitigations

| Risk | Impact | Probability | Mitigation |
|------|--------|-------------|------------|
| [Risk description] | High/Med/Low | High/Med/Low | [Strategy] |

## References

- [Related spec 1](path/to/spec.md)
- [Existing code](path/to/code.ts)

## Changelog

### v1.0.0 (2025-01-13)
- Initial specification
```

**Auto-Check**:
- [ ] All required sections present?
- [ ] Version and status clearly marked?
- [ ] Acceptance criteria testable?
- [ ] Implementation phases defined?

---

### Pattern 2: Concrete Examples (No Vague Language)

All requirements must have concrete, measurable, testable criteria. Zero ambiguity.

❌ **WRONG - Vague requirements**:
```markdown
## Requirements

- The system should be fast
- The UI should be user-friendly
- The code should be maintainable
- Error handling should be good
```

✅ **CORRECT - Concrete requirements**:
```markdown
## Requirements

### Performance (NFR-1)
- API response time: <10ms (p95)
- WebSocket latency: <100ms
- Bundle size: <500KB gzipped
- Time to Interactive: <2s on 3G

**Measurement**: Lighthouse CI, WebPageTest

### User Experience (FR-1)
- All forms validate on blur
- Error messages display within 100ms
- Success feedback shows within 200ms
- Keyboard navigation: Tab order follows visual layout

**Validation**: Cypress E2E tests, Accessibility audit

### Code Quality (NFR-2)
- TypeScript strict mode: no `any`
- Test coverage: >80% lines
- Cyclomatic complexity: <10 per function
- No ESLint errors

**Enforcement**: Pre-commit hooks, CI pipeline

### Error Handling (NFR-3)
- All API calls wrapped in try/catch
- User-facing errors logged to Sentry
- Retry logic for transient failures (3 attempts, exponential backoff)
- Graceful degradation on service unavailability

**Testing**: Error injection tests, Chaos engineering
```

**Auto-Check**:
- [ ] Every requirement has measurable criterion?
- [ ] Measurement method specified?
- [ ] Validation/enforcement strategy defined?
- [ ] No words like "should", "might", "probably"?

---

### Pattern 3: Version Evolution (v1 → v2 Pattern)

When evolving existing specs, document the evolution clearly. Don't lose context.

❌ **WRONG - Delete and rewrite**:
```bash
# Delete old spec
rm specs/old-feature.md

# Write new spec from scratch
# (loses historical context, architectural decisions)
```

✅ **CORRECT - Evolve and archive**:
```markdown
# Feature Name v2.0

**Status**: In Development
**Version**: v2.0.0
**Previous Version**: [v1.0 (Archived)](../archive/v1-features/feature-name.md)
**Evolution Rationale**: [Why we're changing]

## Changes from v1.0

### What's Different
- ❌ Removed: [Feature/approach from v1]
  - **Reason**: [Technical justification]
- ✅ Added: [New feature/approach in v2]
  - **Benefit**: [Improvement over v1]
- 🔄 Modified: [Changed feature]
  - **v1 Behavior**: [...]
  - **v2 Behavior**: [...]
  - **Migration**: [How to upgrade]

### What's Preserved
- ✅ Database schema (95% compatible)
- ✅ API contracts (backwards compatible)
- ✅ Core business logic

### Migration Guide
1. Step 1: [...]
2. Step 2: [...]

## v2.0 Specification

[Full spec follows same structure as Pattern 1]
```

**File Structure**:
```
specs/
├── archive/
│   └── v1-features/
│       └── feature-name-v1.md  ← Archived, not deleted
├── current/
│   └── feature-name-v2.md      ← Active spec
└── INDEX.md                     ← Links to both versions
```

**Auto-Check**:
- [ ] Archived old spec instead of deleting?
- [ ] Documented rationale for changes?
- [ ] Migration guide provided?
- [ ] Backwards compatibility addressed?

---

### Pattern 4: Dual Perspective Validation

Every spec must pass both PO and Technical Analyst review criteria.

❌ **WRONG - Single perspective**:
```markdown
## Requirements

- Implement microservices architecture with event sourcing
- Use CQRS pattern for read/write separation
- Deploy to Kubernetes with Istio service mesh
- Implement SAGA pattern for distributed transactions
```
**Problem**: Over-engineered, no PO pragmatism ("Will this help developers?")

✅ **CORRECT - Dual perspective validated**:
```markdown
## Technical Approach

### PO Perspective: Pragmatic Questions
- ❓ Do we need microservices? Current traffic: 100 req/min, monolith handles 10K/min
  - **Decision**: Start with modular monolith, extract services only when needed
- ❓ Is CQRS necessary? Current read/write ratio: 60/40
  - **Decision**: Simple CRUD for v1, CQRS only if read-heavy emerges
- ❓ Why Kubernetes? Team has 2 developers, no DevOps
  - **Decision**: Docker Compose locally, consider managed PaaS (Render, Fly.io)

### Technical Analyst Perspective: Architecture Validation
- ✅ Modular monolith allows future extraction if needed
- ✅ Database indexes cover query patterns (95% queries <10ms)
- ✅ API design follows REST conventions (cacheable, stateless)
- ✅ TypeScript strict mode prevents runtime errors
- ⚠️ Missing: Rate limiting for public endpoints
  - **Action**: Add rate limiting (100 req/min per IP)

### Final Decision
**Approach**: Pragmatic monolith with clean module boundaries
- Simple deployment (Docker Compose)
- Easy debugging (single process)
- Fast iteration (no distributed complexity)
- Future-proof (modules can extract to services if needed)

**Avoided**: Premature optimization, unnecessary complexity, DevOps overhead
```

**Auto-Check**:
- [ ] PO pragmatic questions asked?
- [ ] Technical soundness validated?
- [ ] Avoided over-engineering?
- [ ] Decision rationale documented?

---

### Pattern 5: Implementation Phasing (Incremental Delivery)

Break work into phases with clear dependencies and deliverables.

❌ **WRONG - Big bang implementation**:
```markdown
## Implementation

Build the entire system:
- Frontend (Vue 3)
- Backend (Bun)
- Database (PostgreSQL)
- Real-time (WebSocket)
- Monitoring (Grafana)

**Timeline**: 6 weeks
```

✅ **CORRECT - Phased delivery**:
```markdown
## Implementation Phases

### Phase 0: Infrastructure (Week 1)
**Goal**: Working local development environment
**Deliverable**: Developer can run `docker compose up` and see "Hello World"

- [ ] Docker Compose setup (PostgreSQL, Redis)
- [ ] Database schema with migrations
- [ ] Backend scaffolding (Bun + basic health check)
- [ ] Frontend scaffolding (Vite + Vue 3)

**Acceptance**: All devs can run locally without errors

---

### Phase 1: Core CRUD (Week 2)
**Goal**: Working API with basic operations
**Deliverable**: Can create, read, update, delete entities via API
**Depends on**: Phase 0

- [ ] API routes (POST, GET, PUT, DELETE /entities)
- [ ] Zod validation for inputs
- [ ] PostgreSQL queries with parameterized statements
- [ ] Basic error handling (400, 404, 500)
- [ ] API tests (80% coverage)

**Acceptance**: Postman collection with all CRUD operations passing

---

### Phase 2: Real-time Updates (Week 3)
**Goal**: WebSocket broadcasting of changes
**Deliverable**: Frontend auto-updates when data changes
**Depends on**: Phase 1

- [ ] WebSocket server setup
- [ ] Redis pub/sub for broadcasting
- [ ] Frontend WebSocket composable
- [ ] Auto-reconnection logic
- [ ] E2E test: Create entity in tab A, see update in tab B

**Acceptance**: Real-time updates work with <100ms latency

---

### Phase 3: UI Polish (Week 4)
**Goal**: Production-ready interface
**Deliverable**: Usable UI with error states
**Depends on**: Phase 2

- [ ] Loading states
- [ ] Error boundaries
- [ ] Empty states
- [ ] Form validation
- [ ] Accessibility audit (WCAG 2.1 AA)

**Acceptance**: Manual QA checklist 100% passed
```

**Dependency Graph**:
```
Phase 0 (Infrastructure)
    ↓
Phase 1 (CRUD)
    ↓
Phase 2 (Real-time)
    ↓
Phase 3 (UI Polish)
```

**Auto-Check**:
- [ ] Each phase has clear goal and deliverable?
- [ ] Dependencies explicitly stated?
- [ ] Acceptance criteria testable?
- [ ] Phases can be demoed independently?

---

## Anti-Patterns

### Anti-Pattern 1: Marketing Speak in Technical Specs

❌ **ANTI-PATTERN**:
```markdown
## Our Revolutionary AI-Powered Solution

Leveraging cutting-edge machine learning algorithms and state-of-the-art
natural language processing, our platform delivers unprecedented insights
with industry-leading performance. Our game-changing approach disrupts
traditional paradigms and empowers users with next-generation capabilities.
```

✅ **CORRECT**:
```markdown
## AI Analysis Feature

**Purpose**: Detect repeated errors in event logs using pattern matching

**Approach**:
- Sliding window (last 100 events)
- Hash-based deduplication
- Count frequency >3 in 60s → Alert

**Performance**: <50ms per analysis, runs every 60s

**No ML required**: Simple string matching + counting
```

**Why It Matters**: Developers need facts, not hype. Clear technical approach enables implementation.

---

### Anti-Pattern 2: Vague Acceptance Criteria

❌ **ANTI-PATTERN**:
```markdown
## Acceptance Criteria

- [ ] System works correctly
- [ ] Performance is good
- [ ] UI looks nice
- [ ] Code is clean
```

✅ **CORRECT**:
```markdown
## Acceptance Criteria

### Functional (Must Pass)
- [ ] User can create account with email+password
- [ ] Email validation prevents invalid formats
- [ ] Password requires 8+ chars, 1 uppercase, 1 number
- [ ] Success message shows within 200ms
- [ ] Error states display for: email taken, weak password, network error

### Performance (Must Pass)
- [ ] API /register endpoint responds <100ms (p95)
- [ ] Bundle size increase <50KB
- [ ] Lighthouse performance score >90

### Security (Must Pass)
- [ ] Passwords hashed with bcrypt (cost factor 12)
- [ ] CSRF token required for registration
- [ ] Rate limit: 5 attempts/hour per IP

### Code Quality (Should Pass)
- [ ] Test coverage >80% for registration flow
- [ ] No ESLint errors
- [ ] TypeScript strict mode (no `any`)
```

**Why It Matters**: Testable criteria enable automated validation and prevent scope creep.

---

### Anti-Pattern 3: Missing Migration Strategy

❌ **ANTI-PATTERN**:
```markdown
# Database Schema v2

We're changing the schema:

```sql
-- New schema
CREATE TABLE users_v2 (
  id UUID PRIMARY KEY,
  email TEXT,
  full_name TEXT  -- Changed from first_name, last_name
);
```

[No mention of existing data, migration path, or rollback]
```

✅ **CORRECT**:
```markdown
# Database Schema v2

## Changes from v1

### Schema Diff
```sql
-- v1 (Current)
CREATE TABLE users (
  id UUID PRIMARY KEY,
  email TEXT,
  first_name TEXT,
  last_name TEXT
);

-- v2 (Proposed)
CREATE TABLE users (
  id UUID PRIMARY KEY,
  email TEXT,
  full_name TEXT  -- Combines first_name + last_name
);
```

### Migration Strategy

**Phase 1: Dual Write (Week 1)**
- Add `full_name` column (nullable)
- Application writes to both old and new columns
- Background job: Populate `full_name` from `first_name` + `last_name`

**Phase 2: Verify (Week 2)**
- Monitor: 100% of rows have `full_name`
- Test: All queries work with new column
- Rollback plan: Drop `full_name`, continue with old columns

**Phase 3: Dual Read (Week 3)**
- Application reads from `full_name` (fallback to old columns)
- Monitor error rates
- Rollback: Switch back to old columns

**Phase 4: Cleanup (Week 4)**
- Drop `first_name`, `last_name` columns
- Update TypeScript types
- Remove fallback logic

**Rollback at any phase**: Revert code, keep all columns (no data loss)

### SQL Migration Script
```sql
-- migration_001_add_full_name.sql
ALTER TABLE users ADD COLUMN full_name TEXT;

-- migration_002_populate_full_name.sql
UPDATE users
SET full_name = CONCAT(first_name, ' ', last_name)
WHERE full_name IS NULL;

-- migration_003_drop_old_columns.sql (Only after 100% confidence)
-- ALTER TABLE users DROP COLUMN first_name;
-- ALTER TABLE users DROP COLUMN last_name;
```

### Validation Queries
```sql
-- Check migration progress
SELECT
  COUNT(*) as total,
  COUNT(full_name) as migrated,
  COUNT(*) FILTER (WHERE full_name IS NULL) as remaining
FROM users;
```

**Why It Matters**: Zero-downtime migrations prevent outages. Rollback plan reduces risk.

---

## Validation Checklist

Before finalizing any spec, verify against this checklist:

### Structure & Format (20 points)
- [ ] All required sections present (10 pts)
- [ ] Version and status clearly marked (5 pts)
- [ ] Changelog with rationale (5 pts)

### Clarity & Precision (25 points)
- [ ] Zero vague language ("should", "might", "good") (10 pts)
- [ ] Concrete examples for all requirements (10 pts)
- [ ] Measurable acceptance criteria (5 pts)

### Dual Perspective (25 points)
- [ ] PO pragmatic questions answered (10 pts)
- [ ] Technical soundness validated (10 pts)
- [ ] Avoided over-engineering (5 pts)

### Implementation Guidance (20 points)
- [ ] Phased delivery plan (10 pts)
- [ ] Dependencies clearly stated (5 pts)
- [ ] Migration/rollback strategy (5 pts)

### Completeness (10 points)
- [ ] Risks identified with mitigations (5 pts)
- [ ] References to related specs/code (5 pts)

### **Total: __/100**

**Minimum Score**: 85/100 for production use
**Target Score**: 95+/100

---

## Usage Examples

### Example 1: Creating New Feature Spec

**Scenario**: User wants to add "Export to CSV" feature

**Spec Architect Process**:
1. **PO Questions**:
   - Why CSV? (Most users request Excel, not CSV)
   - What's the use case? (Offline analysis, import to other tools)
   - Frequency? (Once per month per user)

2. **Technical Analysis**:
   - Data volume? (Max 10K rows)
   - Client-side or server-side? (Client: <1K rows, Server: >1K rows)
   - Security? (Personal data in export, needs audit log)

3. **Spec Output**:
```markdown
# CSV Export Feature

**Status**: Approved
**Version**: v1.0.0

## Overview
Enable users to export event data to CSV format for offline analysis.

## Requirements

### Functional
- FR-1: Export button in event table header
- FR-2: Max 10,000 rows per export
- FR-3: Audit log entry created for each export (GDPR compliance)

### Non-Functional
- NFR-1: Export completes <5s for 10K rows
- NFR-2: No server load (client-side generation)
- NFR-3: Works offline (uses cached data)

## Technical Design

**Approach**: Client-side generation using `papaparse`
- Rationale: <1K typical usage, 10K max, no server cost
- Library: papaparse (5KB gzipped, 4M downloads/month)
- Format: RFC 4180 compliant

## Implementation

### Phase 1: Basic Export (Week 1)
- [ ] Install papaparse
- [ ] Export button UI
- [ ] Generate CSV from visible rows
- [ ] Download via blob URL

### Phase 2: Advanced Options (Week 2)
- [ ] Column selection UI
- [ ] Date format options
- [ ] Include/exclude filters

**Acceptance**: Manual QA with 10K rows <5s
```

---

### Example 2: Evolving Existing Spec

**Scenario**: Poneglyph v1 (Event observability) → v2 (Agent orchestration)

**Spec Architect Process**:
1. **Analyze v1**: What works? What's reusable?
2. **Archive Strategy**: Keep infrastructure specs, archive UI specs
3. **Evolution Doc**: Document changes clearly

**Output**: [See Pattern 3 example above]

---

## References

### Poneglyph System Examples

| Pattern | File Path | Description |
|---------|-----------|-------------|
| Good spec structure | `specs/phase-0-infrastructure/02_docker_setup.md` | Clear requirements, phases |
| Database schema | `specs/phase-0-infrastructure/03_database_schema.md` | Migrations, indexes |
| API specification | `specs/phase-1-backend/02_api_routes.md` | Endpoints, validation |

### Spec-Driven Development Resources
- [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119) - Requirement keywords (MUST, SHOULD)
- [IEEE 830-1998](https://standards.ieee.org/standard/830-1998.html) - Software requirements specification
- [C4 Model](https://c4model.com/) - System architecture diagrams

---

## Success Criteria

After using this skill, specs should:
- ✅ Be implementable without asking clarifying questions
- ✅ Pass both PO (pragmatic) and Technical Analyst (sound) review
- ✅ Have measurable acceptance criteria (no ambiguity)
- ✅ Include phased delivery plan with dependencies
- ✅ Score 95+/100 on validation checklist
- ✅ Enable parallel work (clear interfaces between phases)

---

**Skill Version**: 1.0.0
**Project**: Poneglyph System (and reusable for other projects)
**Methodology**: Spec-Driven Development with Dual Perspective
**Output**: Production-ready technical specifications