Skip to content

Commit f0c5cb7

Browse files
authored
chore(specs): updated spec driven workflow (#138)
Relocate specifications to a new `specs` directory and update agent workflows to support the Gemini CLI and Codex, improving organization and functionality.
1 parent 67ca8b5 commit f0c5cb7

File tree

24 files changed

+1811
-1134
lines changed

24 files changed

+1811
-1134
lines changed

.claude/AGENTS.md

Lines changed: 406 additions & 506 deletions
Large diffs are not rendered by default.

.claude/agents/docs-vision.md

Lines changed: 309 additions & 68 deletions
Large diffs are not rendered by default.

.claude/agents/expert.md

Lines changed: 135 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ Domain expert for SQLSpec implementation. Handles all technical work: core devel
1919

2020
## Implementation Workflow
2121

22+
Codex or Gemini CLI can emulate this workflow without the `/implement` command. When prompted to “run the implementation phase” for a workspace, either assistant must follow every step below, then continue with the Testing and Docs & Vision sequences described in their respective agent guides. Always read the active workspace in `specs/active/{requirement}/` (or `requirements/{requirement}/` if legacy) before making changes. Claude should rely on `/implement` unless explicitly directed to operate manually.
23+
2224
### Step 1: Read the Plan
2325

2426
Always start by understanding the full scope:
2527

2628
```python
2729
# Read PRD from workspace
28-
Read("requirements/{requirement}/prd.md")
30+
Read("specs/active/{requirement}/prd.md")
2931

3032
# Check tasks list
31-
Read("requirements/{requirement}/tasks.md")
33+
Read("specs/active/{requirement}/tasks.md")
3234

3335
# Review research findings
34-
Read("requirements/{requirement}/research/plan.md")
36+
Read("specs/active/{requirement}/research/plan.md")
3537
```
3638

3739
### Step 2: Research Implementation Details
@@ -207,26 +209,105 @@ make lint
207209
make fix
208210
```
209211

210-
### Step 6: Update Workspace
212+
### Step 6: Auto-Invoke Testing Agent (MANDATORY)
213+
214+
After implementation is complete, automatically invoke the Testing agent:
215+
216+
```python
217+
# Invoke Testing agent as subagent
218+
Task(
219+
subagent_type="testing",
220+
description="Create comprehensive test suite",
221+
prompt=f"""
222+
Create comprehensive tests for the implemented feature in specs/active/{requirement}.
223+
224+
Requirements:
225+
1. Read specs/active/{requirement}/prd.md for acceptance criteria
226+
2. Read specs/active/{requirement}/recovery.md for implementation details
227+
3. Create unit tests for all new functionality
228+
4. Create integration tests for all affected adapters
229+
5. Test edge cases (empty results, errors, boundaries)
230+
6. Achieve >80% coverage
231+
7. Update specs/active/{requirement}/tasks.md marking test phase complete
232+
8. Update specs/active/{requirement}/recovery.md with test results
233+
234+
All tests must pass before returning control to Expert agent.
235+
"""
236+
)
237+
```
238+
239+
### Step 7: Auto-Invoke Docs & Vision Agent (MANDATORY)
240+
241+
After tests pass, automatically invoke the Docs & Vision agent:
242+
243+
```python
244+
# Invoke Docs & Vision agent as subagent
245+
Task(
246+
subagent_type="docs-vision",
247+
description="Documentation, quality gate, knowledge capture, and archive",
248+
prompt=f"""
249+
Complete the documentation, quality gate, knowledge capture, and archival process for specs/active/{requirement}.
250+
251+
Phase 1 - Documentation:
252+
1. Read specs/active/{requirement}/prd.md for feature details
253+
2. Update project documentation (Sphinx)
254+
3. Create/update guides in docs/guides/
255+
4. Validate code examples work
256+
5. Build documentation without errors
257+
258+
Phase 2 - Quality Gate:
259+
1. Verify all PRD acceptance criteria met
260+
2. Verify all tests passing
261+
3. Check code standards compliance (AGENTS.md)
262+
4. BLOCK if any criteria not met
263+
264+
Phase 3 - Knowledge Capture:
265+
1. Analyze implementation for new patterns
266+
2. Extract best practices and conventions
267+
3. Update AGENTS.md with new patterns
268+
4. Update relevant guides in docs/guides/
269+
5. Document patterns with working examples
270+
271+
Phase 4 - Re-validation:
272+
1. Re-run tests after documentation updates
273+
2. Rebuild documentation to verify no errors
274+
3. Check pattern consistency across project
275+
4. Verify no breaking changes introduced
276+
5. BLOCK if re-validation fails
277+
278+
Phase 5 - Cleanup & Archive:
279+
1. Remove all tmp/ files
280+
2. Move specs/active/{requirement} to specs/archive/
281+
3. Generate completion report
282+
283+
Return comprehensive completion summary when done.
284+
"""
285+
)
286+
```
287+
288+
### Step 8: Update Workspace
211289

212-
Track progress in `requirements/{requirement}/`:
290+
Track progress in `specs/active/{requirement}/`:
213291

214292
```markdown
215293
# In tasks.md, mark completed items:
216294
- [x] 2. Core implementation
217295
- [x] 3. Adapter-specific code
218-
- [ ] 4. Testing ← UPDATE THIS
296+
- [x] 4. Testing (via Testing agent)
297+
- [x] 5. Documentation (via Docs & Vision agent)
298+
- [x] 6. Knowledge Capture (via Docs & Vision agent)
299+
- [x] 7. Archived (via Docs & Vision agent)
219300
```
220301

221302
```markdown
222303
# In recovery.md, update status:
223304
## Current Status
224-
Status: Testing
225-
Last updated: 2025-10-09
305+
Status: Complete - archived
306+
Last updated: 2025-10-19
226307

227-
## Next Steps
228-
- Complete integration tests for asyncpg
229-
- Add test for edge case: empty result set
308+
## Final Summary
309+
Implementation, testing, documentation, and knowledge capture complete.
310+
Spec archived to specs/archive/{requirement}/
230311
```
231312

232313
## Database Adapter Implementation
@@ -339,45 +420,42 @@ mcp__zen__debug(
339420
# Continue until root cause found...
340421
```
341422

342-
## Handoff to Testing Agent
343-
344-
When implementation complete:
345-
346-
1. **Mark tasks complete:**
347-
348-
```markdown
349-
- [x] 2. Core implementation
350-
- [x] 3. Adapter-specific code
351-
- [ ] 4. Testing ← HAND OFF TO TESTING AGENT
352-
```
353-
354-
2. **Update recovery.md:**
423+
## Automated Workflow
355424

356-
```markdown
357-
## Current Status
358-
Status: Ready for testing
359-
Files modified:
360-
- sqlspec/adapters/asyncpg/driver.py
361-
- sqlspec/core/result.py
425+
The Expert agent orchestrates a complete workflow:
362426

363-
## Next Steps
364-
Testing agent should:
365-
- Add unit tests for new methods
366-
- Add integration tests for asyncpg
367-
- Verify edge cases handled
368-
```
369-
370-
3. **Notify user:**
371-
372-
```
373-
Implementation complete!
427+
```
428+
┌─────────────────────────────────────────────────────────────┐
429+
│ EXPERT AGENT │
430+
│ │
431+
│ 1. Read Plan & Research │
432+
│ 2. Implement Feature │
433+
│ 3. Self-Test & Verify │
434+
│ 4. ──► Auto-Invoke Testing Agent (subagent) │
435+
│ │ │
436+
│ ├─► Create unit tests │
437+
│ ├─► Create integration tests │
438+
│ ├─► Test edge cases │
439+
│ └─► Verify coverage & all tests pass │
440+
│ 5. ──► Auto-Invoke Docs & Vision Agent (subagent) │
441+
│ │ │
442+
│ ├─► Update documentation │
443+
│ ├─► Quality gate validation │
444+
│ ├─► Update AGENTS.md with new patterns │
445+
│ ├─► Update guides with new patterns │
446+
│ ├─► Re-validate (tests, docs, consistency) │
447+
│ ├─► Clean tmp/ and archive │
448+
│ └─► Generate completion report │
449+
│ 6. Return Complete Summary │
450+
└─────────────────────────────────────────────────────────────┘
451+
```
374452

375-
Modified files:
376-
- [sqlspec/adapters/asyncpg/driver.py](sqlspec/adapters/asyncpg/driver.py#L42-L67)
377-
- [sqlspec/core/result.py](sqlspec/core/result.py#L123)
453+
**IMPORTANT**: The Expert agent MUST NOT mark implementation complete until:
378454

379-
Next: Invoke Testing agent to create comprehensive tests.
380-
```
455+
1. Testing agent confirms all tests pass
456+
2. Docs & Vision agent confirms quality gate passed
457+
3. Docs & Vision agent confirms knowledge captured in AGENTS.md and guides
458+
4. Spec is properly archived to specs/archive/
381459

382460
## Tools Available
383461

@@ -397,7 +475,7 @@ When implementation complete:
397475
# User: "Implement connection pooling for asyncpg"
398476

399477
# 1. Read plan
400-
Read("requirements/asyncpg-pooling/prd.md")
478+
Read("specs/active/asyncpg-pooling/prd.md")
401479

402480
# 2. Research
403481
Read("docs/guides/adapters/postgres.md")
@@ -413,11 +491,14 @@ Edit(
413491
new_string="pool = await asyncpg.create_pool(**pool_config)"
414492
)
415493

416-
# 4. Test
494+
# 4. Test locally
417495
Bash(command="uv run pytest tests/integration/test_adapters/test_asyncpg/ -v")
418496

419-
# 5. Update workspace
420-
Edit(file_path="requirements/asyncpg-pooling/tasks.md", ...)
497+
# 5. Auto-invoke Testing agent (creates comprehensive tests)
498+
Task(subagent_type="testing", description="Create test suite", prompt=...)
499+
500+
# 6. Auto-invoke Docs & Vision agent (docs, QA, knowledge, archive)
501+
Task(subagent_type="docs-vision", description="Complete workflow", prompt=...)
421502
```
422503

423504
## Success Criteria
@@ -427,4 +508,7 @@ Edit(file_path="requirements/asyncpg-pooling/tasks.md", ...)
427508
**Tests pass** - `make lint` and `make test` pass
428509
**Performance considered** - SQLglot and mypyc patterns followed
429510
**Workspace updated** - tasks.md and recovery.md current
430-
**Clean handoff** - Next agent (Testing/Docs) can resume easily
511+
**Testing agent invoked** - Tests created and passing
512+
**Docs & Vision invoked** - Documentation, quality gate, knowledge capture, and archive complete
513+
**Spec archived** - Moved to specs/archive/
514+
**Knowledge captured** - AGENTS.md and guides updated with new patterns

.claude/agents/planner.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Strategic planning agent for SQLSpec development. Creates research-grounded, mul
1414
1. **Research-Grounded Planning** - Consult guides, docs, and best practices before planning
1515
2. **Multi-Session Planning** - Use zen planner for structured, resumable plans
1616
3. **Consensus Verification** - Get multi-model agreement on complex decisions
17-
4. **Session Continuity** - Produce detailed artifacts in `requirements/` workspace
17+
4. **Session Continuity** - Produce detailed artifacts in `specs/active/` workspace
1818

1919
## Planning Workflow
2020

21+
Codex or Gemini CLI can mirror this workflow without using `/plan`. When either assistant is asked to “plan {feature}”, it must follow every step below, create or update the workspace at `specs/active/{requirement}/` (fallback `requirements/{requirement}/`), and generate the same artifacts the Planner agent would produce. Claude should continue to rely on the `/plan` command unless instructed otherwise.
22+
2123
### Step 1: Understand Requirements
2224

2325
```python
@@ -111,10 +113,10 @@ mcp__zen__consensus(
111113

112114
### Step 5: Create Workspace Artifacts
113115

114-
Create requirement folder in `requirements/`:
116+
Create requirement folder in `specs/active/`:
115117

116118
```bash
117-
mkdir -p requirements/{requirement-slug}/{research,tmp}
119+
mkdir -p specs/active/{requirement-slug}/{research,tmp}
118120
```
119121

120122
**Required files:**
@@ -230,14 +232,14 @@ After planning complete:
230232
1. **Verify workspace created**:
231233

232234
```bash
233-
ls -la requirements/{requirement-slug}/
235+
ls -la specs/active/{requirement-slug}/
234236
# Should show: prd.md, tasks.md, research/, tmp/, recovery.md
235237
```
236238

237239
2. **Notify user**:
238240

239241
```
240-
Planning complete! Workspace created at `requirements/{requirement-slug}/`.
242+
Planning complete! Workspace created at `specs/active/{requirement-slug}/`.
241243
242244
Next: Invoke Expert agent to begin implementation.
243245
```
@@ -290,6 +292,6 @@ mcp__zen__planner(
290292
**Research complete** - All relevant guides consulted
291293
**Plan structured** - Zen planner workflow used
292294
**Decisions verified** - Consensus on complex choices
293-
**Workspace created** - `requirements/{requirement}/` fully populated
295+
**Workspace created** - `specs/active/{requirement}/` fully populated
294296
**Resumable** - recovery.md enables session continuity
295297
**Standards followed** - CLAUDE.md patterns enforced

.claude/agents/testing.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ Comprehensive testing specialist for SQLSpec. Creates pytest-based unit and inte
1919

2020
## Testing Workflow
2121

22+
Codex or Gemini CLI can execute this workflow directly. When prompted to “perform the testing phase” for a workspace, either assistant must read the existing plan, follow every step below, and produce the same artifacts and coverage validation that the Testing agent would return. Claude should continue to use `/test` unless instructed otherwise.
23+
2224
### Step 1: Read Implementation
2325

2426
Understand what needs testing:
2527

2628
```python
2729
# Read workspace
28-
Read("requirements/{requirement}/prd.md")
29-
Read("requirements/{requirement}/tasks.md")
30+
Read("specs/active/{requirement}/prd.md")
31+
Read("specs/active/{requirement}/tasks.md")
3032

3133
# Read implementation
3234
Read("sqlspec/adapters/asyncpg/driver.py")
@@ -290,7 +292,7 @@ uv run pytest -n 2 --dist=loadgroup
290292
**Mark testing complete:**
291293

292294
```markdown
293-
# In requirements/{requirement}/tasks.md:
295+
# In specs/active/{requirement}/tasks.md:
294296
- [x] 3. Adapter-specific code
295297
- [x] 4. Testing ← JUST COMPLETED
296298
- [ ] 5. Documentation ← HAND OFF TO DOCS & VISION
@@ -308,10 +310,12 @@ Tests added:
308310
All tests passing ✅
309311

310312
## Next Steps
311-
Documentation agent should:
313+
Docs & Vision agent (auto-invoked by Expert) should:
312314
- Update adapter documentation
313-
- Add usage examples
314-
- Update API reference
315+
- Run quality gate
316+
- Capture new testing patterns in AGENTS.md
317+
- Update docs/guides/ with patterns
318+
- Re-validate and archive
315319
```
316320

317321
## Test Organization
@@ -404,7 +408,7 @@ open htmlcov/index.html
404408
assert result is not None
405409
```
406410

407-
## Handoff to Docs & Vision
411+
## Return to Expert Agent
408412

409413
When testing complete:
410414

@@ -418,25 +422,28 @@ When testing complete:
418422
2. **Update workspace:**
419423

420424
```markdown
425+
# In specs/active/{requirement}/tasks.md:
421426
- [x] 4. Testing
422-
- [ ] 5. Documentation ← HAND OFF TO DOCS & VISION
427+
- [ ] 5. Documentation ← EXPERT WILL AUTO-INVOKE DOCS & VISION
423428
```
424429

425-
3. **Notify user:**
430+
3. **Return to Expert with summary:**
426431

427432
```
428433
Testing complete! ✅
429434
430435
Tests added:
431-
- [tests/integration/test_adapters/test_asyncpg/test_connection.py](tests/integration/test_adapters/test_asyncpg/test_connection.py)
432-
- [tests/unit/test_core/test_statement.py](tests/unit/test_core/test_statement.py)
436+
- [tests/integration/test_adapters/test_asyncpg/test_connection.py](tests/integration/test_adapters/test_asyncpg/test_connection.py) (5 tests)
437+
- [tests/unit/test_core/test_statement.py](tests/unit/test_core/test_statement.py) (3 tests)
433438
434439
Coverage: 87% (target: 80%+)
435440
All tests passing: ✅
436441
437-
Next: Invoke Docs & Vision agent for documentation and final review.
442+
Expert agent will now auto-invoke Docs & Vision for documentation, quality gate, knowledge capture, and archival.
438443
```
439444

445+
**Note**: This agent is typically invoked automatically by the Expert agent. It returns control to Expert, which then auto-invokes Docs & Vision agent.
446+
440447
## Tools Available
441448

442449
- **Context7** - Library documentation (pytest, pytest-asyncio, pytest-databases)

0 commit comments

Comments
 (0)