Automated, iterative development workflows with persistent project memory
A complete, production-ready task execution system for Claude Code guardrailed by the Agent Envelope Protocol (AEP) and JSONL-based project memories. It implements structured workflows with TDD enforcement, code review loops, and automatic knowledge capture so every task leaves your codebase smarter than before.
This repository provides a copy/paste workflow system for Claude Code that manages:
- β Task execution - Research β Clarification β Plan β Implement β Review β Validation
- β Systematic debugging - 5 Whys root cause analysis with hypothesis testing
- β Code reviews - Comprehensive PR reviews with GitHub-style output
- β Project memory - Persistent JSONL-based knowledge base that learns from every task
Key benefit: Every task makes the next one easier through automatic knowledge capture.
What this repo includes:
- The
.claude/workflow system that plugs into your own projects
- Quick Start
- Directory Structure
- Workflow Overview
- Core Workflows
- Key Features
- Architecture
- Memory System (JSONL Format)
- Configuration
- Customization
- Examples
- Troubleshooting
- Best Practices
- Claude Code installed
- Git repository (recommended)
-
Clone this repository:
git clone https://github.com/yourusername/claude-code-aep-prompt-workflow.git cd claude-code-aep-prompt-workflow -
Copy the
.claude/directory to your project:cp -r .claude /path/to/your/project/
-
(Optional) Install recommended MCP servers:
# Sequential thinking for systematic analysis claude mcp add --transport stdio sequential-thinking -- npx -y @modelcontextprotocol/server-sequential-thinking # Context7 for documentation lookup (requires setup) # See: https://github.com/context7/mcp-server
cd /path/to/your/project
claude
# Inside Claude Code:
/task "Add a simple hello world function with tests"What happens:
- Memory structure initializes automatically
- Research agent analyzes your codebase
- Plan agent creates a technical todo list (
.claude/TODO.md) - Implement agent follows TDD (Red-Green-Refactor)
- Review agent performs systematic code review
- Validation agent verifies completion and saves learnings to memory
The .claude/ directory that powers this workflow looks like:
.claude/
βββ README.md # Internal workflow documentation
βββ CLAUDE.md # Main memory (auto-imported by Claude Code)
βββ settings.local.json # Local settings (optional)
β
βββ commands/
β βββ task.md # /task workflow entry point
β βββ debug.md # /debug workflow entry point
β βββ code-review.md # /code-review workflow entry point
β
βββ agents/
β βββ research-agent.md # Codebase analysis
β βββ clarification-agent.md # Critical questions
β βββ plan-agent.md # Todo list creation
β βββ implement-agent.md # TDD implementation
β βββ review-agent.md # Code review
β βββ validation-agent.md # Final validation & memory updates
β βββ debug-agent.md # Root cause analysis & debugging
β βββ code-review-agent.md # PR code review specialist
β
βββ skills/ # Reusable Claude Code skills (optional)
β ...
β
βββ memories/
βββ architecture.jsonl # System design decisions
βββ patterns.jsonl # Proven code patterns
βββ libraries.jsonl # Library knowledge & gotchas
βββ review-standards.jsonl # Quality standards
βββ workflow-history.jsonl # Task execution history
At a high level, each /task runs the same end-to-end pipeline:
user β research β clarification β plan β implement β review β validation β user
- research: Understands the codebase and checks existing memories.
- clarification: Asks only critical blocking questions when needed.
- plan: Produces a concrete, test-first technical todo list.
- implement β review: TDD implementation with up to 3 review iterations.
- validation: Verifies the work, updates JSONL memories, and summarizes results back to you.
For a deeper, agent-by-agent breakdown, see .claude/README.md.
Complete TDD workflow with automatic code review:
/task "Add user authentication with JWT tokens"Process: research β clarification β plan β [implement β review] β validation
Output:
- Fully implemented feature with tests
- Updated project memory with patterns and learnings
.claude/TODO.mdwith completed task breakdown
Evidence-based debugging using root cause analysis:
/debug "Database queries timing out in production"Process: symptom analysis β 5 Whys β hypothesis testing β implement fix β validation
Output:
- Root cause identified with evidence
- Fix implemented and tested
- Debug notes saved to memory
Comprehensive technical review with GitHub-style output:
/code-review 123Process: fetch PR diff β 6-category review β generate markdown β save to memory
Output:
temp-123-review.mdwith detailed findings- Severity-based issue classification (π« blocking,
β οΈ major, βΉοΈ minor) - Actionable fix recommendations
Analyze existing codebase and populate memory:
/memory-initProcess: discover architecture β extract patterns β document libraries β save to memory
Output:
- Populated
.claude/memories/*.jsonlfiles - Architecture decisions documented
- Code patterns identified
The system builds a knowledge base that persists across sessions:
.claude/memories/
βββ architecture.jsonl # System design decisions
βββ patterns.jsonl # Proven code patterns
βββ libraries.jsonl # Third-party library gotchas
βββ review-standards.jsonl # Quality standards
βββ workflow-history.jsonl # Task execution history
Benefits:
- Research agent checks memory before searching codebase
- Patterns are automatically reused in new implementations
- Past mistakes inform future reviews
- Team knowledge is captured and shared
Every implementation follows Red-Green-Refactor:
- RED - Write failing test first
- GREEN - Implement minimum code to pass
- REFACTOR - Clean up while keeping tests green
No shortcuts. Tests must pass before moving forward.
Systematic 6-point review with automatic iteration:
- Code Quality (naming, clarity, responsibility)
- Type Safety (no
any/Anytypes) - Testing (coverage, edge cases)
- Performance (optimizations)
- Security (no secrets, validation)
- Best Practices (conventions)
Max 3 iterations before escalating to user.
Agents route automatically using the Agent Envelope Protocol (AEP):
user β research β clarification β plan β implement β review β validation β user
No permission requests between stages. Fully automated pipeline.
| Agent | Responsibility | Tools |
|---|---|---|
| research-agent | Checks memory, analyzes codebase | Read, Grep, Glob, sequential-thinking, context7 |
| clarification-agent | Asks critical questions only | Read, sequential-thinking |
| plan-agent | Creates technical todo list | Read, Grep, sequential-thinking, context7 |
| implement-agent | TDD implementation | Read, Edit, Bash, context7 |
| review-agent | Systematic code review | Read, Grep, Glob, Bash, sequential-thinking |
| validation-agent | Verifies completion, updates memory | Read, Edit, Bash, sequential-thinking |
- debug-agent - 5 Whys root cause analysis, hypothesis testing
- code-review-agent - PR-specific review with tech stack expertise
Memory files use JSONL (JSON Lines) for efficient updates:
- β Append-only without parsing entire file
- β Better git diffs (line-by-line changes)
- β Automatic compaction at 100KB or 200 entries
{"id":"auth-system","type":"architecture","name":"JWT Authentication","when":"2025-11-05","decision":"Centralized JWT auth service","rationale":"Stateless validation across services","files":["auth/jwt.ts"],"tradeoffs":"Benefits: scalable. Limitations: token revocation requires blacklist","dependencies":["jsonwebtoken"],"related":["session-mgmt"],"updated":"2025-11-05"}The workflow dynamically discovers and uses available MCP servers:
# Check what's available
claude mcp listRecommended MCPs:
- sequential-thinking - Systematic analysis (all agents)
- context7 - Documentation lookup (research, plan, implement)
Not required - Workflow works without MCPs, but they enhance quality.
- Create
.claude/agents/your-agent.md - Add to workflow chain in
commands/task.md - Update routing in adjacent agents
See .claude/README.md for details.
- Create
.claude/memories/your-category.jsonl - Add import to
.claude/CLAUDE.md - Update validation-agent to append to it
- Update research-agent to check it
Edit .claude/memories/review-standards.jsonl to add project-specific rules.
/task "Add logout button to header"Result:
- Button component created
- Logout handler implemented
- Unit tests passing
- Memory updated with logout pattern
Time: ~2-3 minutes (depends on codebase size)
/task "Implement real-time notifications with WebSocket"Workflow:
- Research: No WebSocket in memory, searches codebase
- Clarification: Asks about connection strategy, fallback options
- Plan: 8 todos sequenced for TDD
- Implement: Uses context7 to look up WebSocket best practices
- Review: 2 iterations (adds error handling, improves reconnection)
- Validation: Saves WebSocket pattern, library knowledge, architecture
Memory Created:
patterns.jsonl- WebSocket connection patternlibraries.jsonl- ws library usage and gotchasarchitecture.jsonl- Real-time system designworkflow-history.jsonl- Complete implementation record
Time: ~10-15 minutes
/debug "Users getting 500 errors on form submission"Process:
- Symptom Analysis: Reproduce error, check logs
- 5 Whys Analysis:
- Why 500 error? β Missing validation
- Why missing? β Refactor removed it
- Why not caught? β Missing test coverage
- Why no coverage? β Test file not updated
- Root Cause: Incomplete refactor, missing tests
- Hypothesis: Add validation + tests (95% confidence)
- Fix: Implements validation with TDD
- Validation: Confirms error resolved, updates memory
Memory Created:
- Debug investigation notes
- Validation pattern documented
- Test coverage requirement reinforced
Time: ~5-10 minutes
/code-review 456Output: temp-456-review.md
# Code Review: PR #456
**Overall Status**: CHANGES_REQUESTED
## Files Reviewed
- `auth.py` (+34, -12)
- `auth.ts` (+45, -20)
## Detailed Findings
### π« [blocking] Silent Fallback for SECRET_KEY
**File**: `config.py:15`
SECRET_KEY = os.getenv("SECRET_KEY", "default-secret")
**Issue:** Silent fallback compromises security...
**Fix:** Fail fast with explicit error...
### β οΈ [major] Missing Test Coverage
...
## Action Items
1. π« **2 Blocking Issues** - Must fix before merge
2. β οΈ **1 Major Issue** - Should fix before mergeTime: ~3-5 minutes
Symptoms: Agent completes but doesn't route to next agent
Solution:
- Check agent files have
<<<AGENT:COMPLETE>>>blocks - Verify
route_to:field is set correctly - Ensure no text after
<<<END:COMPLETE>>>marker
Symptoms: Multiple test/build processes accumulating
Solution:
- Check for orphaned background processes:
ps aux | grep -E "npm|node|vite|webpack" | grep -v grep
- Kill manually:
pkill -f "npm.*test"
Prevention: Workflow now has strict process management (max 1-2 background tasks per agent).
Symptoms: Research agent doesn't find past patterns
Solution:
- Verify
.claude/CLAUDE.mdimports all memory files - Check memory files use
.jsonlextension - Re-run
/taskto reinitialize structure
Good: /task "Add JWT-based authentication with refresh tokens to the API"
Bad: /task "Add auth"
More detail = better research and planning.
git add .claude/memories/
git commit -m "docs: update project memory"Benefits:
- Team shares knowledge
- Track memory evolution
- Onboard new developers faster
After a few executions, the system will:
- Recognize similar tasks
- Apply proven patterns automatically
- Avoid past gotchas
- Speed up implementation
Check .claude/memories/*.jsonl files to:
- Ensure accuracy
- Consolidate duplicate patterns
- Update outdated information
Automatic compaction happens at 100KB or 200 entries.