Skip to content

Commit 992c192

Browse files
authored
refactor: restructure agent system for consolidation (#149)
Restructures the SQLSpec agent system to eliminate duplication, clarify automated workflows, and establish AGENTS.md as the single source of truth for all AI coding assistants (Claude, Gemini, Codex, etc.).
1 parent 49d74a3 commit 992c192

File tree

17 files changed

+156
-633
lines changed

17 files changed

+156
-633
lines changed

.claude/AGENTS.md

Lines changed: 0 additions & 554 deletions
This file was deleted.

.claude/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../AGENTS.md

.claude/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Enhanced agent system for AI-assisted SQLSpec development, compatible with Claud
77
## Quick Start
88

99
```bash
10-
# 1. Plan a feature
11-
/plan implement vector search for Oracle
10+
# 1. Create PRD for a feature
11+
/prd implement vector search for Oracle
1212

1313
# 2. Implement it
1414
/implement
@@ -22,18 +22,18 @@ Enhanced agent system for AI-assisted SQLSpec development, compatible with Claud
2222

2323
## Core Agents (Enhanced System)
2424

25-
### 1. **Planner** - Strategic Planning
25+
### 1. **PRD** - Product Requirements and Design
2626

2727
- Research-grounded planning (guides + Context7 + WebSearch)
2828
- Structured multi-step plans via zen.planner
2929
- Multi-model consensus via zen.consensus
30-
- Creates workspace in `requirements/{requirement}/`
30+
- Creates workspace in `specs/active/{requirement}/`
3131

32-
**Invoke:** `/plan {feature description}`
32+
**Invoke:** `/prd {feature description}`
3333

3434
### 2. **Expert** - Implementation
3535

36-
- Implements features following CLAUDE.md standards
36+
- Implements features following AGENTS.md standards
3737
- Uses zen.debug for systematic debugging
3838
- Uses zen.thinkdeep for complex decisions
3939
- Uses zen.analyze for code analysis
@@ -63,7 +63,7 @@ Three sequential phases:
6363
## Workspace Structure
6464

6565
```
66-
requirements/
66+
specs/active/
6767
├── {requirement-slug}/ # Active requirement
6868
│ ├── prd.md # Product Requirements Document
6969
│ ├── tasks.md # Implementation checklist
@@ -94,10 +94,10 @@ These guides are the **canonical source of truth** for SQLSpec patterns.
9494

9595
### Full Feature Development
9696

97-
1. **Plan:** Research → Structured planning → Create workspace
97+
1. **PRD:** Research → Structured planning → Create workspace
9898

9999
```bash
100-
/plan add connection pooling for asyncpg
100+
/prd add connection pooling for asyncpg
101101
```
102102

103103
2. **Implement:** Read plan → Implement → Test → Update workspace
@@ -120,7 +120,7 @@ These guides are the **canonical source of truth** for SQLSpec patterns.
120120

121121
### Bug Fix
122122

123-
1. **Plan (optional):** Quick plan for complex bugs
123+
1. **PRD (optional):** Quick PRD for complex bugs
124124
2. **Implement:** Use zen.debug for systematic investigation
125125
3. **Test:** Add regression test
126126
4. **Review:** Quality gate + cleanup
@@ -131,14 +131,14 @@ Resume work across sessions/context resets:
131131

132132
```python
133133
# Find active work
134-
Read("requirements/{requirement}/recovery.md") # Shows status, next steps
135-
Read("requirements/{requirement}/tasks.md") # Shows what's done
136-
Read("requirements/{requirement}/prd.md") # Full context
134+
Read("specs/active/{requirement}/recovery.md") # Shows status, next steps
135+
Read("specs/active/{requirement}/tasks.md") # Shows what's done
136+
Read("specs/active/{requirement}/prd.md") # Full context
137137
```
138138

139139
## Code Quality Standards
140140

141-
All agents enforce [CLAUDE.md](../CLAUDE.md) standards:
141+
All agents enforce [AGENTS.md](../AGENTS.md) standards:
142142

143143
### ✅ ALWAYS
144144

@@ -160,13 +160,13 @@ All agents enforce [CLAUDE.md](../CLAUDE.md) standards:
160160

161161
Structured multi-step planning workflow
162162

163-
**Used by:** Planner
163+
**Used by:** PRD
164164

165165
### zen.consensus
166166

167167
Multi-model decision verification (gemini-2.5-pro, gpt-5)
168168

169-
**Used by:** Planner, Expert
169+
**Used by:** PRD, Expert
170170

171171
### zen.debug
172172

@@ -217,7 +217,7 @@ Current best practices (2025+)
217217
**MANDATORY after every `/review`:**
218218

219219
1. Remove all `tmp/` directories
220-
2. Archive completed requirement to `requirements/archive/`
220+
2. Archive completed requirement to `specs/active/archive/`
221221
3. Keep only last 3 active requirements
222222
4. Archive planning reports to `.claude/reports/archive/`
223223

@@ -227,8 +227,8 @@ Current best practices (2025+)
227227

228228
- **[AGENTS.md](AGENTS.md)** - Comprehensive agent coordination guide
229229
- **[../docs/guides/README.md](../docs/guides/README.md)** - Index of all development guides
230-
- **[../requirements/README.md](../requirements/README.md)** - Workspace structure and usage
231-
- **[../CLAUDE.md](../CLAUDE.md)** - Code quality standards (mandatory reading)
230+
- **[../specs/active/README.md](../specs/active/README.md)** - Workspace structure and usage
231+
- **[../AGENTS.md](../AGENTS.md)** - Code quality standards (mandatory reading)
232232

233233
## Archive
234234

@@ -249,15 +249,15 @@ Run enhancement bootstrap again when:
249249

250250
- **2025-10-09:** Major enhancement
251251
- Consolidated guides to `docs/guides/`
252-
- Created 4 core agents (Planner, Expert, Testing, Docs & Vision)
253-
- Added `requirements/` workspace system
252+
- Created 4 core agents (PRD, Expert, Testing, Docs & Vision)
253+
- Added `specs/active/` workspace system
254254
- Added mandatory cleanup protocols
255-
- Created workflow commands (`/plan`, `/implement`, `/test`, `/review`)
255+
- Created workflow commands (`/prd`, `/implement`, `/test`, `/review`)
256256
- Archived old agents and guides
257257

258258
## See Also
259259

260260
- [Agent Coordination Guide](AGENTS.md) - Detailed agent workflows
261-
- [Code Quality Standards](../CLAUDE.md) - MANDATORY coding standards
261+
- [Code Quality Standards](../AGENTS.md) - MANDATORY coding standards
262262
- [Development Guides](../docs/guides/) - Canonical pattern reference
263-
- [Workspace Guide](../requirements/README.md) - Workspace management
263+
- [Workspace Guide](../specs/active/README.md) - Workspace management

.claude/agents/docs-vision.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: docs-vision
33
description: Documentation excellence, quality gate validation, and workspace cleanup specialist - ensures code quality, comprehensive docs, and clean workspace before completion
44
tools: mcp__context7__resolve-library-id, mcp__context7__get-library-docs, WebSearch, Read, Write, Edit, Bash, Glob, Grep
55
model: sonnet
6+
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
7+
guides_root: ../docs/guides/
8+
workspace_root: ../specs/active/
69
---
710

811
# Docs & Vision Agent
@@ -203,7 +206,7 @@ Quality gate MUST pass before moving to Phase 3 (Cleanup).
203206
### Step 1: Read Quality Standards
204207

205208
```python
206-
Read("CLAUDE.md") # Code quality standards
209+
Read("AGENTS.md") # Code quality standards
207210
Read("docs/guides/testing/testing.md") # Testing standards
208211
```
209212

@@ -814,6 +817,6 @@ def test_asyncpg_connection_basic():
814817
**Phase 4 Complete** - Re-validation passed after updates
815818
**Phase 5 Complete** - Workspace cleaned and archived
816819
**All tests pass** - `make lint && make test` success
817-
**Standards followed** - CLAUDE.md compliance
820+
**Standards followed** - AGENTS.md compliance
818821
**Knowledge preserved** - Future implementations benefit
819822
**Clean handoff** - Ready for PR/commit

.claude/agents/expert.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: expert
33
description: SQLSpec domain expert with comprehensive knowledge of database adapters, SQL parsing, type system, storage backends, and Litestar integration
44
tools: mcp__context7__resolve-library-id, mcp__context7__get-library-docs, WebSearch, mcp__zen__analyze, mcp__zen__thinkdeep, mcp__zen__debug, Read, Edit, Bash, Glob, Grep, Task
55
model: sonnet
6+
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
7+
guides_root: ../docs/guides/
8+
workspace_root: ../specs/active/
69
---
710

811
# Expert Agent
@@ -14,12 +17,12 @@ Domain expert for SQLSpec implementation. Handles all technical work: core devel
1417
1. **Implementation** - Write clean, type-safe, performant code
1518
2. **Debugging** - Use zen.debug for systematic root cause analysis
1619
3. **Deep Analysis** - Use zen.thinkdeep for complex architectural decisions
17-
4. **Code Quality** - Enforce CLAUDE.md standards ruthlessly
20+
4. **Code Quality** - Enforce AGENTS.md standards ruthlessly
1821
5. **Documentation** - Update technical docs and code comments
1922

2023
## Implementation Workflow
2124

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.
25+
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}/` before making changes. Claude should rely on `/implement` unless explicitly directed to operate manually.
2326

2427
### Step 1: Read the Plan
2528

@@ -53,7 +56,7 @@ Read("docs/guides/architecture/architecture.md")
5356
Read("docs/guides/architecture/data-flow.md")
5457

5558
# Code quality standards
56-
Read("CLAUDE.md")
59+
Read("AGENTS.md")
5760

5861
# Quick reference for common patterns
5962
Read("docs/guides/quick-reference/quick-reference.md")
@@ -74,7 +77,7 @@ mcp__context7__get-library-docs(
7477

7578
### Step 3: Implement with Quality Standards
7679

77-
**MANDATORY CODE QUALITY RULES** (from CLAUDE.md):
80+
**MANDATORY CODE QUALITY RULES** (from AGENTS.md):
7881

7982
**DO:**
8083

@@ -457,6 +460,49 @@ The Expert agent orchestrates a complete workflow:
457460
3. Docs & Vision agent confirms knowledge captured in AGENTS.md and guides
458461
4. Spec is properly archived to specs/archive/
459462

463+
## Automated Sub-Agent Invocation
464+
465+
**IMPORTANT**: The Expert agent **automatically invokes** Testing and Docs & Vision agents upon completing implementation. This is **NOT optional** - it's part of the core workflow.
466+
467+
### When to Auto-Invoke
468+
469+
After implementation is complete and local tests pass:
470+
471+
1. **Always invoke Testing agent** (`subagent_type="testing"`):
472+
- Creates comprehensive unit and integration tests
473+
- Verifies test coverage meets thresholds (80%+ adapters, 90%+ core)
474+
- Tests edge cases, errors, concurrency
475+
- Ensures all tests pass
476+
477+
2. **Always invoke Docs & Vision agent** (`subagent_type="docs-vision"`):
478+
- Phase 1: Updates documentation
479+
- Phase 2: Runs quality gate validation (BLOCKS if fails)
480+
- Phase 3: Captures new patterns in AGENTS.md and guides
481+
- Phase 4: Re-validates after documentation updates
482+
- Phase 5: Cleans workspace and archives to specs/archive/
483+
484+
### Invocation Pattern
485+
486+
```python
487+
# After implementation complete and local tests pass:
488+
489+
# 1. Invoke Testing agent
490+
Task(
491+
subagent_type="testing",
492+
description="Create comprehensive test suite",
493+
prompt="Create unit and integration tests for [feature]. Verify coverage and edge cases."
494+
)
495+
496+
# 2. Invoke Docs & Vision agent
497+
Task(
498+
subagent_type="docs-vision",
499+
description="Documentation, QA, and archival",
500+
prompt="Complete 5-phase workflow: docs, quality gate, knowledge capture, re-validation, archive."
501+
)
502+
```
503+
504+
**Result**: When `/implement` completes, the feature is fully implemented, tested, documented, quality-validated, patterns captured, and archived. No manual `/test` or `/review` commands needed!
505+
460506
## Tools Available
461507

462508
- **zen.debug** - Systematic debugging workflow
@@ -503,7 +549,7 @@ Task(subagent_type="docs-vision", description="Complete workflow", prompt=...)
503549

504550
## Success Criteria
505551

506-
**Standards followed** - CLAUDE.md compliance
552+
**Standards followed** - AGENTS.md compliance
507553
**Guides consulted** - Referenced relevant docs
508554
**Tests pass** - `make lint` and `make test` pass
509555
**Performance considered** - SQLglot and mypyc patterns followed
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
---
2-
name: planner
3-
description: Multi-session planning agent for complex SQLSpec development spanning multiple files, adapters, and features
2+
name: prd
3+
description: Product Requirements and Design agent for complex SQLSpec development spanning multiple files, adapters, and features
44
tools: mcp__zen__planner, mcp__context7__resolve-library-id, mcp__context7__get-library-docs, WebSearch, mcp__zen__consensus, Read, Glob, Grep
55
model: sonnet
6+
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
7+
guides_root: ../docs/guides/
8+
workspace_root: ../specs/active/
69
---
710

8-
# Planner Agent
11+
# PRD Agent
912

10-
Strategic planning agent for SQLSpec development. Creates research-grounded, multi-session plans for complex features spanning multiple database adapters, storage backends, or framework integrations.
13+
Product Requirements and Design agent for SQLSpec development. Creates research-grounded, multi-session plans for complex features spanning multiple database adapters, storage backends, or framework integrations.
1114

1215
## Core Responsibilities
1316

@@ -18,7 +21,7 @@ Strategic planning agent for SQLSpec development. Creates research-grounded, mul
1821

1922
## Planning Workflow
2023

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.
24+
Codex or Gemini CLI can mirror this workflow without using `/prd`. When either assistant is asked to "create PRD for {feature}", it must follow every step below, create or update the workspace at `specs/active/{requirement}/` , and generate the same artifacts the PRD agent would produce. Claude should continue to rely on the `/prd` command unless instructed otherwise.
2225

2326
### Step 1: Understand Requirements
2427

@@ -49,7 +52,7 @@ Codex or Gemini CLI can mirror this workflow without using `/plan`. When either
4952
Read("docs/guides/testing/testing.md")
5053

5154
# Code quality standards
52-
Read("CLAUDE.md")
55+
Read("AGENTS.md")
5356
```
5457

5558
2. **Context7** (for library documentation):
@@ -196,7 +199,7 @@ Read(f"docs/guides/adapters/{adapter}.md")
196199

197200
## Anti-Patterns to Avoid
198201

199-
Based on CLAUDE.md standards:
202+
Based on AGENTS.md standards:
200203

201204
**NO defensive programming**:
202205

@@ -238,7 +241,7 @@ After planning complete:
238241

239242
2. **Notify user**:
240243

241-
```
244+
```text
242245
Planning complete! Workspace created at `specs/active/{requirement-slug}/`.
243246
244247
Next: Invoke Expert agent to begin implementation.
@@ -294,4 +297,4 @@ mcp__zen__planner(
294297
**Decisions verified** - Consensus on complex choices
295298
**Workspace created** - `specs/active/{requirement}/` fully populated
296299
**Resumable** - recovery.md enables session continuity
297-
**Standards followed** - CLAUDE.md patterns enforced
300+
**Standards followed** - AGENTS.md patterns enforced

.claude/agents/testing.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: testing
33
description: Comprehensive testing specialist for SQLSpec - creates unit tests, integration tests, fixtures, and validates test coverage across all database adapters
44
tools: mcp__context7__resolve-library-id, mcp__context7__get-library-docs, Read, Write, Edit, Bash, Glob, Grep
55
model: sonnet
6+
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
7+
guides_root: ../docs/guides/
8+
workspace_root: ../specs/active/
69
---
710

811
# Testing Agent
@@ -87,7 +90,7 @@ def test_statement_parameter_replacement():
8790
assert "$1" in converted.sql
8891
```
8992

90-
**Testing standards (from CLAUDE.md):**
93+
**Testing standards (from AGENTS.md):**
9194

9295
**DO:**
9396

.claude/commands/implement.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ The expert should:
2323
- Use zen.analyze for code analysis
2424
- Update workspace progress continuously
2525

26-
**This ONE command handles:**
27-
✅ Implementation
28-
✅ Testing (automatic via Testing agent)
29-
✅ Documentation (automatic via Docs & Vision)
30-
✅ Quality gate (automatic via Docs & Vision)
31-
**Knowledge capture** (automatic via Docs & Vision)
32-
**Re-validation** (automatic via Docs & Vision)
26+
**This ONE command automatically runs the entire workflow:**
27+
✅ Implementation (Expert agent)
28+
`/test` - Testing (automatic via Testing agent invocation)
29+
`/review` - Documentation, quality gate, knowledge capture (automatic via Docs & Vision agent invocation)
3330
✅ Archival (automatic via Docs & Vision)
3431

35-
**After implementation:**
36-
Feature is complete, tested, documented, patterns captured, and archived!
32+
**Equivalent to running:** `/implement` → auto-runs `/test` → auto-runs `/review` → auto-archives
33+
34+
**After completion:**
35+
Feature is fully implemented, comprehensively tested, documented, quality-validated, patterns captured in AGENTS.md and guides, and archived to specs/archive/!
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Create a comprehensive, research-grounded plan for: {{prompt}}
1+
Create a comprehensive Product Requirements Document and design plan for: {{prompt}}
22

3-
Invoke the Planner agent to:
3+
Invoke the PRD agent to:
44

55
1. **Research** - Consult docs/guides/, Context7, and WebSearch
66
2. **Plan** - Use zen.planner for structured planning
@@ -12,7 +12,7 @@ Invoke the Planner agent to:
1212
- recovery.md (Session resume instructions)
1313
- tmp/ (temporary files directory)
1414

15-
The planner should reference:
15+
The PRD agent should reference:
1616

1717
- docs/guides/adapters/ for database-specific patterns
1818
- docs/guides/performance/ for optimization strategies

0 commit comments

Comments
 (0)