diff --git a/.serena/.gitignore b/.serena/.gitignore deleted file mode 100644 index 14d86ad..0000000 --- a/.serena/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/cache diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 0abb295..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,136 +0,0 @@ -# CHANGELOG - - - -## v0.1.0 (2025-11-29) - -- Initial Release - -## v0.4.0 (2025-09-10) - -### Features - -- Add production logging system + project structure improvements - ([#6](https://github.com/ai-enhanced-engineer/ai-base-template/pull/6), - [`ed20bb5`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/ed20bb5a4b9e6c1f5a50379bf7e32c9406c40f22)) - -### Refactoring - -- Modernize and streamline logging system with functionality-driven tests - ([#6](https://github.com/ai-enhanced-engineer/ai-base-template/pull/6), - [`ed20bb5`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/ed20bb5a4b9e6c1f5a50379bf7e32c9406c40f22)) - -- Modernize logging module and simplify tests - ([#6](https://github.com/ai-enhanced-engineer/ai-base-template/pull/6), - [`ed20bb5`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/ed20bb5a4b9e6c1f5a50379bf7e32c9406c40f22)) - -- Rename ai_base_template/ to src/ and integrate formatting - ([#6](https://github.com/ai-enhanced-engineer/ai-base-template/pull/6), - [`ed20bb5`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/ed20bb5a4b9e6c1f5a50379bf7e32c9406c40f22)) - - -## v0.3.0 (2025-09-02) - -### Documentation - -- Showcase production logging system in README - ([#5](https://github.com/ai-enhanced-engineer/ai-base-template/pull/5), - [`75ab7ad`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/75ab7ad3fa027447c2b360fece807fac2d737141)) - -- Transform README to production-first pedagogical approach - ([#5](https://github.com/ai-enhanced-engineer/ai-base-template/pull/5), - [`75ab7ad`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/75ab7ad3fa027447c2b360fece807fac2d737141)) - -- Transform README to production-first pedagogical approach - ([#4](https://github.com/ai-enhanced-engineer/ai-base-template/pull/4), - [`7f109e7`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/7f109e7ba6a968d7b67caed39f58d0a6c3fdf83e)) - -### Features - -- Add structured logging and integrate formatting into CI/CD - ([#5](https://github.com/ai-enhanced-engineer/ai-base-template/pull/5), - [`75ab7ad`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/75ab7ad3fa027447c2b360fece807fac2d737141)) - -### Refactoring - -- Improve import organization and remove redundant docstrings - ([#5](https://github.com/ai-enhanced-engineer/ai-base-template/pull/5), - [`75ab7ad`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/75ab7ad3fa027447c2b360fece807fac2d737141)) - - -## v0.2.1 (2025-08-21) - -### Bug Fixes - -- Add sync target and update CI workflows - ([#3](https://github.com/ai-enhanced-engineer/ai-base-template/pull/3), - [`95cb140`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/95cb140b7bc7f2a619bbe0731b96129ccf42a122)) - -### Chores - -- Improve Makefile interface and consistency - ([#3](https://github.com/ai-enhanced-engineer/ai-base-template/pull/3), - [`95cb140`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/95cb140b7bc7f2a619bbe0731b96129ccf42a122)) - -### Refactoring - -- Improve Makefile with better naming and consistency - ([#3](https://github.com/ai-enhanced-engineer/ai-base-template/pull/3), - [`95cb140`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/95cb140b7bc7f2a619bbe0731b96129ccf42a122)) - - -## v0.2.0 (2025-08-06) - -### Chores - -- Add pre-commit configuration with Make commands - ([#2](https://github.com/ai-enhanced-engineer/ai-base-template/pull/2), - [`38a8fcc`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/38a8fccd8e882747ec8879ed1c0afd5db9f77ded)) - -### Documentation - -- Add Architecture Decision Record (ADR) - ([#2](https://github.com/ai-enhanced-engineer/ai-base-template/pull/2), - [`38a8fcc`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/38a8fccd8e882747ec8879ed1c0afd5db9f77ded)) - -- Add Architecture Decision Record (ADR) for project structure - ([#2](https://github.com/ai-enhanced-engineer/ai-base-template/pull/2), - [`38a8fcc`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/38a8fccd8e882747ec8879ed1c0afd5db9f77ded)) - -### Features - -- Add Apache 2.0 license ([#2](https://github.com/ai-enhanced-engineer/ai-base-template/pull/2), - [`38a8fcc`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/38a8fccd8e882747ec8879ed1c0afd5db9f77ded)) - -### Refactoring - -- Use Make commands in CI workflow for consistency - ([#2](https://github.com/ai-enhanced-engineer/ai-base-template/pull/2), - [`38a8fcc`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/38a8fccd8e882747ec8879ed1c0afd5db9f77ded)) - -### Testing - -- Verify pre-commit hooks are working - ([#2](https://github.com/ai-enhanced-engineer/ai-base-template/pull/2), - [`38a8fcc`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/38a8fccd8e882747ec8879ed1c0afd5db9f77ded)) - - -## v0.1.0 (2025-08-06) - -### Features - -- Add Apache 2.0 license ([#1](https://github.com/ai-enhanced-engineer/ai-base-template/pull/1), - [`28bc302`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/28bc3025d31029824b72586ce6b41fa6c128844c)) - - -## v0.0.2 (2025-07-31) - -### Bug Fixes - -- Comment out ML dependencies to speed up CI builds - ([`ab0c011`](https://github.com/ai-enhanced-engineer/ai-base-template/commit/ab0c0114d70f745460f532603a4cd90a52d9f00d)) - - -## v0.0.1 (2025-07-31) - -- Initial Release diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..f055a9a --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,34 @@ +# Python Agentic Template + +Autonomous Python template. Describe what you want; agents build it. + +## Workflow + +Run `workflows/PROJECT_INIT_WORKFLOW.md` for the complete specification. + +Phases: **Research → Architecture → MVP → Enhancement** with user approval gates. + +## Development Standards + +### Validation (Required Before Commits) +```bash +make validate-branch # Runs format, lint, type-check, test +``` + +## Artifact Locations + +| Output | Location | +|--------|----------| +| User seeds | `context/PRODUCT.md`, `context/ENGINEERING.md` | +| PRD | `context/PRD.md` | +| Architecture | `ADR.md` | +| Project plan | `context/PROJECT_PLAN.md` | +| Code | `src/*.py` | +| Tests | `tests/test_*.py` | + +## Key Rules + +1. Read all context files before acting +2. Use templates in `workflows/templates/` for output formats +3. Stop at approval gates—don't jump phases +4. Max 3 fix cycles per deliverable, then escalate diff --git a/README.md b/README.md index 1aaf87a..ca5e1b5 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,15 @@ > Describe what you want to build. Let agents build it. -Autonomous multi-agent Python project template. *Part of [Bot Brewers](https://github.com/bot-brewers).* +An autonomous Python project template that bootstraps itself into production-ready code through a multi-agent workflow. ## Why This Template? -**The Problem:** Starting AI/ML projects requires extensive setup—architecture decisions, project structure, testing patterns, CI/CD, logging, and more. Most developers copy-paste from old projects or spend days configuring from scratch. +Starting an AI/ML project means three days of ceremony before writing real code. Project structure. Logging. Tests. CI/CD. Type hints. Pre-commit hooks. -**The Solution:** This template **bootstraps itself** into a complete, production-ready project through a multi-agent workflow. You describe your project in plain language; agents research, plan, and build it. +Most developers copy-paste from old repos or configure from scratch. Both approaches carry technical debt from day one. + +This template bootstraps itself. Describe the project in two seed files; agents research, plan, and implement it with production patterns built in. ## How It Works @@ -54,14 +56,14 @@ Autonomous multi-agent Python project template. *Part of [Bot Brewers](https://g └─────────────────────────────────────────────────────────────────┘ ``` -**Human-in-the-loop**: You approve each phase before continuing. No runaway automation. +You approve each phase before continuing. ## Quick Start 1. **Create your repository**: Click "Use this template" on GitHub 2. **Set up environment**: `make init` 3. **Fill out your seeds**: Edit `context/PRODUCT.md` and `context/ENGINEERING.md` -4. **Start brewing**: In Claude Code, say `"Run the project initialization workflow"` +4. **Start building**: In Claude Code, say `"Run the project initialization workflow"` ### Filling Out Seeds @@ -79,32 +81,26 @@ See `workflows/PROJECT_INIT_WORKFLOW.md` for the complete workflow specification ## What You Get -Beyond the autonomous workflow, this template provides a **production-ready foundation**: +The autonomous workflow is the main attraction, but the template also provides a production-ready foundation: ### Modern Python Tooling -- Python 3.12+, FastAPI, Pydantic -- Type hints throughout +- Python 3.12+ with type hints throughout - uv for fast dependency management +- Ready for any framework you choose ### Production Logging -- Structured JSON logging with structlog -- Correlation ID tracking across requests -- Dual-mode: human-readable (dev) / JSON (prod) +Structured JSON logging with structlog. Correlation ID tracking. Dual-mode output: human-readable for development, JSON for production. ### Development Automation -- Pre-configured linting (Ruff), formatting (Black), type checking (mypy) -- Pre-commit hooks for quality gates -- `make validate-branch` runs all checks +- Ruff (linting), Black (formatting), mypy (types) +- Pre-commit hooks as quality gates +- `make validate-branch` runs everything -### Testing Patterns -- Unit, functional, and integration test structure -- pytest with markers for test organization -- 21+ logging system tests included as examples +### Testing Structure +Unit, functional, and integration test directories with pytest markers. The logging system alone has 21+ tests as examples. ### CI/CD Ready -- GitHub Actions workflows -- Semantic versioning -- Docker-ready structure +GitHub Actions workflows included. Semantic versioning. Docker-ready structure. ## Project Structure @@ -166,14 +162,9 @@ The autonomous workflow ensures these patterns are built in from the start, not ## Who Should Use This -### Teams Starting AI/ML Projects -Stop reinventing infrastructure. Describe your project and let agents build a production-ready foundation. - -### Senior Engineers New to AI -Get the safety rails you're accustomed to in production systems while learning AI concepts. +Starting an AI/ML project and don't want to spend days on infrastructure? This is for you. Senior engineer who expects production-grade tooling from day one? This is for you. Leading a team and want a consistent starting point that embodies engineering discipline? This is for you. -### Technical Leaders -Give your team a consistent, production-ready starting point that embodies engineering best practices. +The common thread: reliability over speed, describing what you want over configuring it manually. ## Learn More @@ -187,18 +178,14 @@ Give your team a consistent, production-ready starting point that embodies engin - [Hidden Technical Debt in ML Systems](https://papers.nips.cc/paper/5656-hidden-technical-debt-in-machine-learning-systems.pdf) ### Technologies -- [FastAPI](https://fastapi.tiangolo.com/) - Modern Python web framework -- [Pydantic](https://docs.pydantic.dev/) - Data validation - [structlog](https://www.structlog.org/) - Structured logging - [uv](https://docs.astral.sh/uv/) - Fast Python package management +- [pytest](https://docs.pytest.org/) - Testing framework +- [Ruff](https://docs.astral.sh/ruff/) - Fast Python linter ## Contributing -When contributing, prioritize: -1. **Reliability over features** -2. **Simplicity over cleverness** -3. **Documentation over assumptions** -4. **Tests over trust** +Prioritize reliability over features, simplicity over cleverness, documentation over assumptions, tests over trust. ## License diff --git a/research/EDA.ipynb b/research/EDA.ipynb deleted file mode 100644 index 91e9588..0000000 --- a/research/EDA.ipynb +++ /dev/null @@ -1,55 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# EDA - Exploratory Data Analysis\n", - "\n", - "This notebook will be continued soon..." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": "# Import production code\nimport sys\nfrom pathlib import Path\n\nsys.path.append(str(Path().parent.absolute()))\n\nimport src\nfrom src.main import get_version, hello_world" - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": "# Explore the package\nprint(f\"Version: {src.__version__}\")\nprint(f\"Hello: {hello_world()}\")\nprint(f\"Get version: {get_version()}\")" - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.7" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} \ No newline at end of file diff --git a/workflows/PROJECT_INIT_WORKFLOW.md b/workflows/PROJECT_INIT_WORKFLOW.md index c556ceb..50d0e69 100644 --- a/workflows/PROJECT_INIT_WORKFLOW.md +++ b/workflows/PROJECT_INIT_WORKFLOW.md @@ -24,6 +24,8 @@ This workflow uses **abstract roles** instead of specific agent names for portab | `architecture` | ADRs, system design, MVP scoping | 2 | project-architect, ml-systems-architect | | `implementation` | Code writing, testing, domain expertise | 3-4 | ai-engineer, backend-engineer, data-engineer, agentic-engineer | | `review` | Test enforcement, code quality auditing | 3-4 | python-code-quality-auditor | +| `domain-expert` | Business alignment, PRD compliance, user value validation | 3-4 feedback | Inferred from PRODUCT.md domain; product-manager as fallback | +| `architecture-reviewer` | Over-engineering detection, ADR compliance, pattern validation | 3-4 feedback | project-architect, ml-systems-architect | **Role Matching Keywords**: @@ -33,6 +35,8 @@ This workflow uses **abstract roles** instead of specific agent names for portab | architecture | architect, design, planning, ADR, system, infrastructure | | implementation | engineer, developer, implement, code, build | | review | review, audit, quality, test, enforce, validate, check, gate | +| domain-expert | domain, business, product, user, requirements, stakeholder | +| architecture-reviewer | architect, design, patterns, system, simplicity, complexity | **Note**: The `implementation` role supports **multiple specialists** - different agents can be assigned to different features based on domain expertise. @@ -48,47 +52,383 @@ This workflow uses **abstract roles** instead of specific agent names for portab | architecture | [pending discovery] | - | ⏳ | | implementation | [pending discovery] | - | ⏳ | | review | [pending discovery] | - | ⏳ | +| domain-expert | [pending discovery] | - | ⏳ | +| architecture-reviewer | [pending discovery] | - | ⏳ | --- -## Phase 0: Agent Discovery +## Workflow State -Before starting the workflow, Claude Code discovers available specialists and maps them to roles. +*Updated automatically during workflow execution. Clear this section after workflow completion or when starting fresh.* + +| Field | Value | +|-------|-------| +| Current Phase | - | +| Current Step | - | +| Last Updated | - | + +### Created Agents (pending validation) + +*List agents created in Phase 0.3, pending restart and validation.* + +| Agent File | Role | Status | +|------------|------|--------| +| - | - | - | + +### Linked Skills + +*Skills linked to created agents (if any).* + +| Agent | Skills | +|-------|--------| +| - | - | + +--- + +## Phase 0: Agent Discovery & Setup + +Before starting the workflow, Claude Code discovers available specialists, identifies gaps, and optionally creates missing specialists tailored to the project. + +``` +Phase 0: Agent Discovery & Setup +├── 0.1: Scan & Match +├── 0.2: Gap Analysis & User Choice +│ ├── [Create] → 0.3 +│ ├── [Generalist] → Phase 1 +│ └── [Hybrid] → 0.3 for selected roles +└── 0.3: Specialist Creation (conditional) +``` + +--- + +### Phase 0.1: Scan & Match **Actions**: 1. Scan for agents at: - Project level: `.claude/agents/*.md` - User level: `~/.claude/agents/*.md` -2. Read agent descriptions and match to roles using keywords -3. Present candidates to user for approval -4. Update "Discovered Agents" section above with selections +2. Read agent descriptions and match to roles using keywords (see Role Matching Keywords table above) +3. Present candidates to user -**User Approval**: +**Output**: -Claude Code presents discovered agents: ``` -Found specialists for this workflow: +Phase 0.1: Agent Discovery +────────────────────────── -research: context-engineer (user) - "Web research and evidence synthesis" -architecture: project-architect (user) - "ADRs and system design" -implementation: ai-engineer (user) - "RAG and LLM integration" - backend-engineer (user) - "APIs and databases" -review: python-code-quality-auditor (user) - "Code quality and test enforcement" +Scanning for specialists... -Approve these selections? [Y/n/modify] +✅ Found: + implementation: backend-engineer (user) - "APIs and databases" + review: python-code-quality-auditor (user) - "Quality gate" + +❌ Missing: + research: No agent found + architecture: No agent found ``` -**If No Matches Found**: +If all roles have matches → Present for approval, update "Discovered Agents" table, proceed to Prerequisites. + +If any roles missing → Proceed to Phase 0.2. + +#### Domain Expert Selection + +The `domain-expert` role requires special handling - it should match the project's domain, not just generic keywords. + +**Selection Logic**: + +1. Analyze `context/PRODUCT.md` for domain keywords +2. Map to appropriate specialist agent +3. If no clear match, ask user ``` -⚠️ WARNING: No specialist found for role [research]. - Workflow will proceed with generalist Claude Code. - Consider creating a specialist agent for better results. +Analyzing PRODUCT.md for domain... + +Domain keywords found: +- "machine learning", "model training" → ML domain +- "e-commerce", "checkout", "cart" → Commerce domain +- "healthcare", "patient", "clinical" → Healthcare domain +- "API", "backend", "database" → Backend/infrastructure domain + +Suggested domain expert: +┌─────────────────────────────────────────────────────────┐ +│ Domain: ML/Data Science │ +│ Recommended: data-science-modeler (user) │ +│ Reason: Keywords "model training", "pipeline" in PRD │ +└─────────────────────────────────────────────────────────┘ + +Accept this selection? [Y/n/specify different] ``` -**After Discovery**: +**Domain-to-Agent Mapping**: + +| Domain Keywords | Suggested Agent | Fallback | +|-----------------|-----------------|----------| +| ML, model, training, prediction | data-science-modeler, ml-research-expert | product-manager | +| API, backend, database, service | backend-engineer | product-manager | +| UI, frontend, component, user interface | frontend-engineer | product-manager | +| Data, ETL, pipeline, warehouse | data-engineer | product-manager | +| Agent, autonomous, LLM, RAG | ai-engineer, agentic-engineer | product-manager | +| (No clear match) | Ask user | product-manager | + +**If user must specify**: + +``` +No clear domain match found in PRODUCT.md. -Update the "Discovered Agents" table above, then proceed to Prerequisites. +What domain expertise is most relevant for validating this project? +Examples: "ML/data science", "backend services", "e-commerce", "healthcare" + +Domain: _ +``` + +--- + +### Phase 0.2: Gap Analysis & User Choice + +When roles are missing, present options to the user: + +``` +Phase 0.2: Gap Resolution +───────────────────────── + +For missing roles, choose an option: + +[1] Create specialists (recommended) + → I'll design agents based on your PRODUCT.md and ENGINEERING.md + → Follows Anthropic best practices + → Requires Claude Code restart after creation + +[2] Proceed with generalists + → Claude Code handles these roles directly + → Works but less specialized + → No restart needed + +[3] Hybrid approach + → Select which roles get specialists vs. generalists + +Your choice: _ +``` + +**If user chooses [1] Create** → Proceed to Phase 0.3 for all missing roles. + +**If user chooses [2] Generalist** → Update "Discovered Agents" table with "generalist" entries, proceed to Prerequisites. + +**If user chooses [3] Hybrid** → Ask which roles to create specialists for: + +``` +Which roles should get specialists? (comma-separated) +Missing: research, architecture + +Create specialists for: _ +``` + +Then proceed to Phase 0.3 for selected roles, mark others as "generalist". + +--- + +### Phase 0.3: Specialist Creation + +**Prerequisite**: User must have filled out `context/PRODUCT.md` and `context/ENGINEERING.md` seed documents. + +#### 0.3.1: Analyze Seeds for Domain Context + +Read seed documents and extract: + +| From PRODUCT.md | Extract | +|-----------------|---------| +| Problem statement | Domain keywords | +| Target users | Interaction patterns | +| Core requirements | Tool/skill needs | +| Success criteria | Validation focus | + +| From ENGINEERING.md | Extract | +|---------------------|---------| +| Tech stack | Specific technology expertise | +| Constraints | What agent should avoid/prefer | +| Architecture patterns | DDD, event-driven, etc. | +| Non-functional requirements | Performance, security focus | + +#### 0.3.2: Fetch Best Practices + +Use `claude-code-guide` subagent to fetch Anthropic documentation on: +- Agent file structure and frontmatter +- Effective agent prompts +- Skill integration patterns + +#### 0.3.3: Draft Agent Files + +Generate agent markdown files following this structure: + +```markdown +--- +name: [role]-specialist +description: [One-line domain-specific description] +--- + +# [Role] Specialist for [Project Name] + +You are a [role] specialist for [domain] projects. + +## Expertise +[Derived from seeds - specific technologies, patterns, domain knowledge] + +## Responsibilities +[Role-specific tasks from workflow] + +## Constraints +[From ENGINEERING.md - what to avoid, preferences] + +## Skills +[Optional: linked skills if user requested] +``` + +#### 0.3.4: Present Drafts for User Approval + +``` +Phase 0.3.4: Agent Draft Review +─────────────────────────────── + +I've drafted the following specialists based on your seeds: + +┌─────────────────────────────────────────────────────────┐ +│ research-specialist.md │ +├─────────────────────────────────────────────────────────┤ +│ Description: Research ML pipeline technologies and │ +│ synthesize evidence on [domain] patterns │ +│ │ +│ Expertise: [tech stack from seeds] │ +│ Skills: [suggested skills] │ +└─────────────────────────────────────────────────────────┘ + +[View full draft? Y/n] + +Options: +[1] Approve all drafts +[2] Modify a draft (opens for editing) +[3] Regenerate with different focus +[4] Cancel specialist creation +``` + +#### 0.3.5: Skills Configuration + +Before creating agent files, ask about skills: + +``` +Skills Configuration +──────────────────── + +Would you like to link specific skills to these agents? + +Options: +[1] Auto-suggest skills based on project domain + → I'll recommend skills matching your seeds +[2] Manually specify skills for each agent +[3] Skip - let Claude Code auto-load skills as needed +[4] Create new project-specific skills + → I'll help design skills tailored to this project (sub-workflow) + +Your choice: _ +``` + +If user chooses [4], trigger skill creation sub-workflow before continuing. + +#### 0.3.6: Create Agent Files + +Create approved agents in `.claude/agents/`: + +``` +Creating agents... + ✅ .claude/agents/research-specialist.md + ✅ .claude/agents/architecture-specialist.md + +Updating workflow state... +``` + +Update the "Discovered Agents" table with created agents (status: "created, pending validation"). + +#### 0.3.7: Update Workflow State + +Update the "Workflow State" section (below) with: +- Current phase: 0.3 +- Current step: pending_restart +- Created agents list +- Linked skills (if any) + +#### 0.3.8: Prompt User to Restart + +``` +─────────────────────────────────────────────────────────── +Agent files created successfully! + +Claude Code needs to restart to load the new agents. + +Please: +1. Exit this session (Ctrl+C or type 'exit') +2. Restart Claude Code in this directory +3. Say: "Continue project initialization workflow" + +Progress saved to this file (Workflow State section below). +─────────────────────────────────────────────────────────── +``` + +#### 0.3.9: Post-Restart Validation + +After user restarts and continues, validate each created agent: + +``` +Phase 0.3.9: Agent Validation +───────────────────────────── + +Validating created agents... + +research-specialist: + Invoking: "Introduce yourself in one sentence." + Response: "I research ML pipeline technologies, synthesize + evidence on XGBoost and FastAPI patterns, and prepare + knowledge packages for architecture decisions." + ✅ Agent responds correctly. + +architecture-specialist: + Invoking: "Introduce yourself in one sentence." + Response: "I design system architectures for data pipelines, + create ADRs, and define MVP scope with MoSCoW prioritization." + ✅ Agent responds correctly. +``` + +**If validation fails**: + +``` +❌ Agent 'research-specialist' failed to load. + Error: [error message] + + Options: + [1] Review and fix the agent file manually + [2] Delete and recreate + [3] Skip - use generalist for this role +``` + +#### 0.3.10: Finalize Discovery + +After validation: +1. Update "Discovered Agents" table with final status (✅) +2. Clear "Workflow State" section (workflow complete) +3. Proceed to Prerequisites + +--- + +### Generalist Fallback Behavior + +When proceeding with generalists (by choice or after failed creation): + +- Claude Code handles the role directly without a specialist agent +- Quality is acceptable but less domain-specific +- User can create specialists later and re-run Phase 0 + +Update "Discovered Agents" table: +```markdown +| research | generalist (Claude Code) | - | ✅ | +``` --- @@ -364,17 +704,159 @@ If a deliverable fails review 3 times: - `make validate-branch` passes - Coverage >= 80% for new code +--- + +### 3.4 Domain & Architecture Feedback + +**Roles**: `domain-expert` + `architecture-reviewer` (read-only, sequential) +**Triggered**: After all deliverables pass code review, before phase gate approval. + +This feedback gate ensures implementations are aligned with business outcomes and not over-engineered. + +#### 3.4.1 Domain Expert Review (First) + +**Role**: `domain-expert` + +**Input**: +- Implemented code from Phase 3 +- `context/PRD.md` - Business requirements +- `context/PROJECT_PLAN.md` - MVP scope + +**Checks**: +1. Does implementation serve stated user needs from PRD? +2. Is it aligned with success criteria? +3. Does it address the core problem statement? +4. Are there unnecessary features not in scope? + +**Report Format**: + +``` +## Domain Alignment Review +**Phase**: 3 (MVP) +**Status**: ALIGNED | MISALIGNED | OVER-SCOPED + +### Alignment with PRD +- [ ] Addresses problem statement +- [ ] Serves target users +- [ ] Meets success criteria +- [ ] Within defined scope + +### Concerns +[List any business/domain misalignments] + +### Recommendations +[Suggested adjustments] +``` + +**If MISALIGNED or OVER-SCOPED** → Blocking. Implementation must fix issues before proceeding. + +#### 3.4.2 Architecture Review (Second) + +**Role**: `architecture-reviewer` + +**Input**: +- Implemented code from Phase 3 +- `ADR.md` - Architecture decisions +- Domain review findings (from 3.4.1) + +**Checks**: +1. Does implementation follow patterns in ADR.md? +2. Is complexity justified by requirements? +3. Are there simpler alternatives for current phase? +4. Is it over-engineered for MVP scope? + +**Over-Engineering Signals**: +- Abstractions without current use cases +- Premature optimization +- Features beyond Must-Have scope +- Configuration/flexibility not requested +- Layers/indirection without clear benefit + +**Report Format**: + +``` +## Architecture Review +**Phase**: 3 (MVP) +**Status**: APPROPRIATE | OVER-ENGINEERED | UNDER-DESIGNED + +### ADR Compliance +- [ ] Follows ADR-001: [decision] +- [ ] Follows ADR-002: [decision] +... + +### Complexity Assessment +- Complexity level: [Simple | Moderate | Complex] +- Justified by requirements: [Yes | No] + +### Over-Engineering Detected +[List any unnecessary complexity] + +### Simplification Recommendations +[Concrete suggestions to reduce complexity] +``` + +**If OVER-ENGINEERED** → Blocking. Implementation must simplify before proceeding. + +#### 3.4.3 Combined Feedback Summary + +``` +Phase 3.4: Domain & Architecture Feedback +───────────────────────────────────────── + +┌─────────────────────────────────────────────────────────┐ +│ DOMAIN REVIEW │ +│ Status: ALIGNED │ +│ ✓ Addresses problem statement │ +│ ✓ Serves target users │ +│ ✓ Within MVP scope │ +└─────────────────────────────────────────────────────────┘ + +┌─────────────────────────────────────────────────────────┐ +│ ARCHITECTURE REVIEW │ +│ Status: OVER-ENGINEERED │ +│ ✗ Abstract factory pattern not needed for 2 variants │ +│ ✗ Configuration system beyond requirements │ +│ │ +│ Recommendations: │ +│ 1. Replace factory with simple if/else │ +│ 2. Hardcode config values, add flexibility in Phase 4 │ +└─────────────────────────────────────────────────────────┘ + +Blocking Issues: 2 +Action Required: Simplify implementation before approval gate +``` + +#### 3.4.4 Fix Feedback Issues + +**Role**: `implementation` + +If domain or architecture review identifies blocking issues: + +1. Address each blocking issue from feedback +2. Apply simplification recommendations +3. Re-run `make test` to ensure changes don't break tests +4. Return to 3.4.1 for re-review (max 2 feedback cycles) + +**Loop Control**: +- Maximum **2 feedback cycles** per phase +- If still failing after 2 cycles → **escalate to user** + +--- + ### [APPROVAL GATE 3] User validates: - MVP functionality (end-to-end) -- All deliverables passed review loop +- All deliverables passed code review loop +- Domain alignment review passed (ALIGNED) +- Architecture review passed (APPROPRIATE) - Test coverage meets requirements **Options**: - ✅ **Approve** - Proceed to Phase 4 - 🐛 **Request fixes** - Specify additional issues to address - ✏️ **Adjust scope** - Modify MVP boundaries +- 🔄 **Re-run feedback** - Request another domain/architecture review --- @@ -415,18 +897,60 @@ Phase 4 follows the same **Implement → Review → Fix** loop as Phase 3 for ea **Actions**: 1. Run same validation as Phase 3.2 (tests, naming, coverage, quality) 2. Generate review report -3. If PASS → proceed to user approval +3. If PASS → proceed to domain/architecture feedback 4. If FAIL → implementation agent fixes (max 3 cycles) --- -### 4.3 Feature Approval +### 4.3 Domain & Architecture Feedback + +**Roles**: `domain-expert` + `architecture-reviewer` (read-only, sequential) +**Triggered**: After feature passes code review, before feature approval. + +Same structure as Phase 3.4, applied per feature: + +#### 4.3.1 Domain Expert Review + +**Checks**: +1. Does this feature serve stated user needs from PRD? +2. Is it aligned with roadmap priorities? +3. Does it integrate well with existing MVP? +4. Is it within the Should-Have/Could-Have scope for this phase? + +**Report Format**: Same as Phase 3.4.1 + +**If MISALIGNED** → Blocking. Must fix before approval. + +#### 4.3.2 Architecture Review + +**Checks**: +1. Does feature follow established patterns from Phase 3? +2. Is complexity appropriate for a Phase 4 enhancement? +3. Does it introduce unnecessary technical debt? +4. Is it over-engineered for the stated requirement? + +**Report Format**: Same as Phase 3.4.2 + +**If OVER-ENGINEERED** → Blocking. Must simplify before approval. + +#### 4.3.3 Fix Feedback Issues + +If blocking issues found: +1. Address domain/architecture concerns +2. Re-run tests +3. Return to 4.3.1 for re-review (max 2 cycles) + +--- + +### 4.4 Feature Approval ### [APPROVAL GATE per feature] -After review passes, user validates: +After code review AND domain/architecture feedback pass, user validates: - Feature functionality -- Review report shows PASS +- Code review report shows PASS +- Domain alignment review passed (ALIGNED) +- Architecture review passed (APPROPRIATE) - Integration with existing MVP **Options**: @@ -434,13 +958,15 @@ After review passes, user validates: - 🔄 **Request changes** - Modify current feature - ⏭️ **Skip to next** - Move to next roadmap item - 🛑 **Stop** - End enhancement phase +- 🔄 **Re-run feedback** - Request another domain/architecture review --- **Output**: Enhanced system with additional features **Success Criteria**: -- Each feature passes review loop +- Each feature passes code review loop +- Each feature passes domain/architecture feedback - `make validate-branch` passes - Coverage maintained >= 80% @@ -597,6 +1123,93 @@ Templates in `workflows/templates/` define output formats. Agents use these to p - Ask agent to re-read specific context file - Update context if requirements changed +### "Created agent doesn't load after restart" + +**Cause**: Syntax error in agent file or invalid frontmatter + +**Fix**: +- Check agent file has valid YAML frontmatter (between `---` markers) +- Verify `name` and `description` fields are present +- Look for special characters that need escaping +- Try recreating the agent using Phase 0.3 + +### "Agent validation fails with error" + +**Cause**: Agent file malformed or Claude Code can't invoke it + +**Fix**: +- Review error message for specifics +- Compare agent file structure to working examples in `~/.claude/agents/` +- Delete and recreate the agent +- Fall back to generalist for this role + +### "Workflow state shows pending_restart but I already restarted" + +**Cause**: Claude Code didn't detect the continuation prompt + +**Fix**: +- Say exactly: "Continue project initialization workflow" +- Check the "Workflow State" section shows the correct phase +- Manually update "Current Step" to "validation" and re-run + +### "Seeds are empty but I want to create specialists" + +**Cause**: Phase 0.3 requires PRODUCT.md and ENGINEERING.md to design domain-specific agents + +**Fix**: +- Fill out `context/PRODUCT.md` with at least: problem statement, target users, tech stack +- Fill out `context/ENGINEERING.md` with at least: tech preferences, constraints +- Re-run Phase 0.3 + +### "Domain review says MISALIGNED but implementation matches PRD" + +**Cause**: PRD may have evolved since implementation, or domain expert misunderstood context + +**Fix**: +- Review PRD - has it changed since Phase 2? +- Ask domain expert to re-read specific PRD section +- If PRD is outdated, update it and re-run domain review +- Override with user approval if alignment is subjective + +### "Architecture review flags everything as over-engineered" + +**Cause**: Reviewer may be too aggressive, or project genuinely needs simplification + +**Fix**: +- Review specific recommendations - are they actionable? +- Check if ADR.md justifies the complexity (documented decisions) +- If patterns are intentional, add rationale to ADR and re-run review +- Escalate to user if disagreement persists + +### "Implementation keeps failing feedback after simplification" + +**Cause**: Feedback criteria may be too strict, or fundamental approach needs rethinking + +**Fix**: +- After 2 feedback cycles, workflow escalates to user +- User can override with documented risk +- Consider splitting deliverable into smaller pieces +- May need to revisit architecture decisions in ADR.md + +### "No domain expert found for my project type" + +**Cause**: Project domain doesn't match available agents + +**Fix**: +- Use `product-manager` as fallback (general business alignment) +- Create a domain-specific agent using Phase 0.3 +- Specify domain manually when prompted during Phase 0.1 + +### "Domain and architecture reviews contradict each other" + +**Cause**: Different perspectives on what's appropriate + +**Fix**: +- Domain review runs first, architecture considers its findings +- If conflict persists, escalate to user +- User decides which feedback takes priority +- Document decision in ADR.md for future reference + --- ## Agent Best Practices @@ -626,3 +1239,9 @@ After each workflow execution, update this file to: | 2025-11-28 | Reorganized: context/ for seeds, workflows/ for support | Clearer separation of user inputs vs. system files | | 2025-11-28 | Added Phase 0 agent discovery, abstract roles | Workflow portability - users may have different specialists | | 2025-11-28 | Added `review` role with Implement → Review → Fix loop | Enforce test creation and code quality before progression | +| 2025-11-29 | Enhanced Phase 0 with sub-phases 0.1-0.3 for agent creation | Handle missing specialists by offering creation vs. generalist fallback | +| 2025-11-29 | Added Workflow State section for restart recovery | Claude Code requires restart to load new agents; state persistence enables continuation | +| 2025-11-29 | Added skills configuration step in Phase 0.3.5 | Allow users to link existing skills or create project-specific ones | +| 2025-11-29 | Added `domain-expert` and `architecture-reviewer` roles | Validate business alignment and prevent over-engineering | +| 2025-11-29 | Added Phase 3.4 and 4.3 Domain & Architecture Feedback gates | Blocking feedback loop after code review, before approval | +| 2025-11-29 | Added domain expert selection logic to Phase 0.1 | Infer domain from PRODUCT.md, ask user if unclear |