claude-code-generator 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. claude_code_generator-0.1.0.dist-info/METADATA +176 -0
  2. claude_code_generator-0.1.0.dist-info/RECORD +49 -0
  3. claude_code_generator-0.1.0.dist-info/WHEEL +5 -0
  4. claude_code_generator-0.1.0.dist-info/entry_points.txt +2 -0
  5. claude_code_generator-0.1.0.dist-info/licenses/LICENSE +21 -0
  6. claude_code_generator-0.1.0.dist-info/top_level.txt +1 -0
  7. code_generator/__init__.py +3 -0
  8. code_generator/agents.py +177 -0
  9. code_generator/cli.py +49 -0
  10. code_generator/commands/__init__.py +1 -0
  11. code_generator/commands/generate.py +252 -0
  12. code_generator/commands/init.py +72 -0
  13. code_generator/commands/review.py +117 -0
  14. code_generator/commands/status.py +83 -0
  15. code_generator/env.py +55 -0
  16. code_generator/gh.py +331 -0
  17. code_generator/logging_setup.py +73 -0
  18. code_generator/orchestrator/__init__.py +4 -0
  19. code_generator/orchestrator/cycle_loop.py +371 -0
  20. code_generator/orchestrator/phase0_complexity.py +159 -0
  21. code_generator/orchestrator/phase1_plan.py +170 -0
  22. code_generator/orchestrator/phase2_review.py +126 -0
  23. code_generator/orchestrator/phase3_4_implement.py +164 -0
  24. code_generator/orchestrator/phase5_closure.py +154 -0
  25. code_generator/orchestrator/phase6_test.py +98 -0
  26. code_generator/orchestrator/phase7_commit.py +167 -0
  27. code_generator/prompts/__init__.py +86 -0
  28. code_generator/prompts/prompt-phase-0-complexity.md +85 -0
  29. code_generator/prompts/prompt-phase-1-planning.md +209 -0
  30. code_generator/prompts/prompt-phase-2-issue-review.md +84 -0
  31. code_generator/prompts/prompt-phase-3-implementation.md +191 -0
  32. code_generator/prompts/prompt-phase-5-final-review.md +135 -0
  33. code_generator/prompts/prompt-phase-6-test.md +102 -0
  34. code_generator/prompts/prompt-phase-7-commit.md +103 -0
  35. code_generator/prompts/prompt-review.md +124 -0
  36. code_generator/runner/__init__.py +26 -0
  37. code_generator/runner/rate_limit.py +113 -0
  38. code_generator/runner/retry.py +165 -0
  39. code_generator/runner/sdk_runner.py +267 -0
  40. code_generator/runner/subprocess_runner.py +200 -0
  41. code_generator/state.py +178 -0
  42. code_generator/templates/__init__.py +1 -0
  43. code_generator/templates/angular.md +12 -0
  44. code_generator/templates/base.md +28 -0
  45. code_generator/templates/fastapi.md +12 -0
  46. code_generator/templates/finance.md +9 -0
  47. code_generator/templates/fullstack.md +24 -0
  48. code_generator/templates/nestjs.md +9 -0
  49. code_generator/templates/python-cli.md +9 -0
@@ -0,0 +1,86 @@
1
+ """Prompt loader for the code-generator orchestrator.
2
+
3
+ Prompt files contain literal curly braces (bash code blocks, JSON schema
4
+ examples, etc.) that would break str.format(). Substitution is done by
5
+ simple text.replace() per placeholder name, which is immune to stray braces.
6
+ """
7
+
8
+ import importlib.resources
9
+
10
+
11
+ class PromptError(ValueError):
12
+ """Raised when a prompt file is unknown or its placeholders are mismatched."""
13
+
14
+
15
+ # Maps each prompt filename to the exact set of placeholder names it accepts.
16
+ # A frozenset() means the file accepts no placeholders (it is fully static).
17
+ PLACEHOLDER_SPEC: dict[str, frozenset[str]] = {
18
+ "prompt-phase-0-complexity.md": frozenset(),
19
+ "prompt-phase-1-planning.md": frozenset(
20
+ {"REQUIREMENTS_PATH", "MILESTONE_TITLE", "CYCLE_SCOPE", "COMPLETED_CYCLES"}
21
+ ),
22
+ "prompt-phase-2-issue-review.md": frozenset({"ISSUE_NUMBER", "PRIMARY_AGENT"}),
23
+ "prompt-phase-3-implementation.md": frozenset(
24
+ {"ISSUE_NUMBER", "PRIMARY_AGENT", "SKILLS"}
25
+ ),
26
+ "prompt-phase-5-final-review.md": frozenset({"MILESTONE_TITLE", "CYCLE_SCOPE"}),
27
+ "prompt-phase-6-test.md": frozenset({"MAX_RETRIES"}),
28
+ "prompt-phase-7-commit.md": frozenset({"CYCLE_NAME", "ISSUES_CLOSED"}),
29
+ "prompt-review.md": frozenset({"CREATE_ISSUES", "SEVERITY_FILTER"}),
30
+ }
31
+
32
+
33
+ def load_prompt(filename: str, **placeholders: object) -> str:
34
+ """Load a prompt file and substitute named placeholders.
35
+
36
+ Placeholder tokens use the syntax ``{NAME_IN_UPPERCASE}``. Substitution
37
+ is done with plain string replacement so that stray ``{`` / ``}`` in the
38
+ template (bash blocks, JSON schema examples) are never misinterpreted.
39
+
40
+ Args:
41
+ filename: One of the 8 registered prompt filenames.
42
+ **placeholders: Keyword arguments whose names must match exactly the set
43
+ declared in PLACEHOLDER_SPEC for this file.
44
+
45
+ Returns:
46
+ The prompt text with all placeholder tokens replaced by their values.
47
+
48
+ Raises:
49
+ PromptError: When *filename* is unrecognised, when required placeholders
50
+ are missing, or when unexpected placeholders are supplied.
51
+ """
52
+ if filename not in PLACEHOLDER_SPEC:
53
+ raise PromptError(f"unknown prompt file: {filename!r}")
54
+
55
+ expected = PLACEHOLDER_SPEC[filename]
56
+ supplied = set(placeholders)
57
+ missing = expected - supplied
58
+ extra = supplied - expected
59
+
60
+ if missing or extra:
61
+ parts: list[str] = []
62
+ if missing:
63
+ parts.append(f"missing: {', '.join(sorted(missing))}")
64
+ if extra:
65
+ parts.append(f"extra: {', '.join(sorted(extra))}")
66
+ raise PromptError("; ".join(parts))
67
+
68
+ text = (
69
+ importlib.resources.files("code_generator.prompts")
70
+ .joinpath(filename)
71
+ .read_text(encoding="utf-8")
72
+ )
73
+
74
+ for name, value in placeholders.items():
75
+ text = text.replace("{" + name + "}", str(value))
76
+
77
+ return text
78
+
79
+
80
+ def available_prompts() -> list[str]:
81
+ """Return the list of registered prompt filenames.
82
+
83
+ Returns:
84
+ Sorted list of the 8 known prompt filenames.
85
+ """
86
+ return sorted(PLACEHOLDER_SPEC)
@@ -0,0 +1,85 @@
1
+ # Prompt — Phase 0: Complexity analysis and cycle decomposition
2
+
3
+ **Model:** `claude-opus-4-6`
4
+ **Tools:** `Read`, `Glob`, `Grep`
5
+ **Output:** structured JSON conforming to the schema defined later in this prompt
6
+ **Placeholders:** none (the prompt is static — the tool reads the requirements file directly)
7
+
8
+ ---
9
+
10
+ ## Prompt
11
+
12
+ You are the `code-generator` orchestrator. Your only task in this phase is to analyze the complexity level of the project described in `.code-generator/requirements.md` and decide whether to generate it in a single cycle or decompose it into multiple cycles ordered by dependency.
13
+
14
+ ### Instructions
15
+
16
+ 1. **Read** `.code-generator/requirements.md` with the `Read` tool.
17
+
18
+ 2. **Analyze** the project by extracting:
19
+ - Number of distinct architectural layers (database, backend API, frontend, infrastructure, authentication, external integration, etc.)
20
+ - Number of described features
21
+ - Estimate of the GitHub issues that will be created
22
+ - Dependencies between layers (example: "the frontend depends on the API" → dependency)
23
+
24
+ 3. **Decide the mode** following these rules:
25
+ - If **≤ 8 estimated issues** AND **≤ 2 architectural layers**: `single` mode (a single cycle with the 7 phases)
26
+ - If **> 8 issues** OR **> 2 layers with mutual dependencies**: `multi-cycle` mode
27
+
28
+ 4. **If multi-cycle**, decompose the project into cycles ordered by dependency. Rules:
29
+ - Every cycle must be **self-contained and committable** (produces an increment that compiles and works)
30
+ - **Foundational layers go first** (database before API, API before frontend)
31
+ - Every cycle has a `depends_on` field listing the IDs of the required previous cycles
32
+ - Every cycle has a human-readable `milestone_title` for the GitHub Milestone (e.g. `"Cycle 1 — Database Layer"`)
33
+ - Maximum **5 cycles** per project
34
+
35
+ 5. **Output** a single JSON object conforming to the following JSON Schema:
36
+
37
+ ```json
38
+ {
39
+ "type": "object",
40
+ "properties": {
41
+ "mode": {"type": "string", "enum": ["single", "multi-cycle"]},
42
+ "reason": {"type": "string"},
43
+ "cycles": {
44
+ "type": "array",
45
+ "items": {
46
+ "type": "object",
47
+ "properties": {
48
+ "id": {"type": "integer"},
49
+ "name": {"type": "string"},
50
+ "milestone_title": {"type": "string"},
51
+ "depends_on": {"type": "array", "items": {"type": "integer"}},
52
+ "scope": {"type": "string"},
53
+ "estimated_issues": {"type": "integer"}
54
+ },
55
+ "required": ["id", "name", "milestone_title", "depends_on", "scope"]
56
+ }
57
+ }
58
+ },
59
+ "required": ["mode", "cycles"]
60
+ }
61
+ ```
62
+
63
+ Example for a full-stack project:
64
+ ```json
65
+ {
66
+ "mode": "multi-cycle",
67
+ "reason": "3 architectural layers with dependencies: DB -> API -> Frontend",
68
+ "cycles": [
69
+ {"id": 1, "name": "Database Layer", "milestone_title": "Cycle 1 — Database Layer", "depends_on": [], "scope": "Schema, ORM models, migrations, repository classes", "estimated_issues": 4},
70
+ {"id": 2, "name": "API Layer", "milestone_title": "Cycle 2 — API Layer", "depends_on": [1], "scope": "REST endpoints, middleware, authentication, validation", "estimated_issues": 6},
71
+ {"id": 3, "name": "Frontend", "milestone_title": "Cycle 3 — Frontend", "depends_on": [2], "scope": "Components, routing, API integration, styling", "estimated_issues": 5}
72
+ ]
73
+ }
74
+ ```
75
+
76
+ ### Constraints
77
+
78
+ - **Do not create files**, do not run `gh`, and do not write code. Only analysis + JSON.
79
+ - **Do not ask the user for confirmation**: decide autonomously. In case of real, insurmountable ambiguity, fall back to `single`.
80
+ - **Do not invent features**: stick to what is written in the requirements file.
81
+ - **Single Responsibility per cycle**: a cycle must have only one architectural responsibility (database OR API, not both mixed together). No speculative generalizations (YAGNI), no "for the future" layers.
82
+
83
+ ### Reasoning example
84
+
85
+ > "The requirements describe a full-stack app with Angular frontend, FastAPI backend, PostgreSQL via Supabase, JWT authentication, and 12 CRUD features. Distinct layers: DB, API, Frontend, Auth. Estimated issues: ~15. Decision: `multi-cycle`. Cycles: (1) Database + Auth, (2) API, (3) Frontend."
@@ -0,0 +1,209 @@
1
+ # Prompt — Phase 1: Planning and GitHub Issues creation
2
+
3
+ **Model:** `claude-opus-4-6`
4
+ **Tools:** `Read`, `Bash`, `Glob`, `Grep`
5
+ **Runtime placeholders:**
6
+ - `{REQUIREMENTS_PATH}` — path of the requirements file (default `.code-generator/requirements.md`)
7
+ - `{CYCLE_SCOPE}` — scope of the current cycle (multi-cycle mode only, otherwise `"the entire project"`)
8
+ - `{MILESTONE_TITLE}` — title of the GitHub Milestone (multi-cycle only)
9
+ - `{COMPLETED_CYCLES}` — list of cycles already completed (multi-cycle only)
10
+
11
+ ---
12
+
13
+ ## Prompt
14
+
15
+ You are a senior architect planning the implementation of a software project. Your task is to read the requirements, produce an implementation plan, and **create the corresponding GitHub Issues** via the `gh` CLI.
16
+
17
+ ### Instructions
18
+
19
+ 1. **Read** `{REQUIREMENTS_PATH}` with the `Read` tool.
20
+
21
+ 2. **Read the agent inventory** in `agents.md` — it contains the 13 available agents (frontend-developer, python-pro, fastapi-expert-agent, nestjs-expert, baml-expert-agent, tailwind-patterns, typescript-pro, ui-ux-designer, riskfolio-expert, flyio-fastapi-deployment-expert, vercel-deployment-specialist, supabase-connection-expert, supabase-auth-linker) and the 4 skills (solid-principles, python-expert, skfolio, yfinance). **Every issue must explicitly declare which agent to use.**
22
+
23
+ 3. **Scope of this cycle:** {CYCLE_SCOPE}.
24
+ In multi-cycle mode, focus EXCLUSIVELY on this scope. The following cycles have already been completed and committed: {COMPLETED_CYCLES}. Read the existing codebase with `Glob` and `Read` to understand what has already been built.
25
+
26
+ 4. **Analyze** the requirements and produce a structured plan:
27
+ - Decompose the features into concrete implementation tasks
28
+ - Every task must be an independent unit of work, testable, completable in a single session
29
+ - Identify the dependencies between tasks (task A blocks task B)
30
+ - Order the tasks so that dependencies are respected
31
+
32
+ 5. **For every task, select the agent and skills** using the matrix below and the tech stack declared in the requirements file read at step 1. The chosen agent will be the one that Phase 3 passes to `ClaudeAgentOptions.agents` during implementation.
33
+
34
+ **Model distribution per phase:**
35
+
36
+ | Phase | Model | Reason |
37
+ |-------|-------|--------|
38
+ | Planning, Review, Closure | **Opus 4.6** (`claude-opus-4-6`) | Complex reasoning, architecture, critical decisions |
39
+ | Implementation, Iteration, Test | **Sonnet 4.6** (`claude-sonnet-4-6`) | Fast coding, good quality/cost ratio |
40
+
41
+ **Agent selection matrix (task-level):**
42
+
43
+ | Task area | Primary agent | Support agents (optional) | Active skills |
44
+ |---|---|---|---|
45
+ | DB schema, migrations, ORM (Python) | `python-pro` | `supabase-connection-expert`, `fastapi-expert-agent` | `solid-principles`, `python-expert` |
46
+ | FastAPI endpoints, auth, middleware | `fastapi-expert-agent` | `python-pro`, `supabase-connection-expert` | `solid-principles`, `python-expert` |
47
+ | NestJS endpoints/modules | `nestjs-expert` | `supabase-connection-expert` | `solid-principles` |
48
+ | Angular components, routing, signals | `frontend-developer` | `typescript-pro`, `ui-ux-designer` | `solid-principles` |
49
+ | Tailwind styling, design tokens, responsive layout | `tailwind-patterns` | `frontend-developer`, `ui-ux-designer` | `solid-principles` |
50
+ | Advanced TypeScript, typing, generics | `typescript-pro` | `frontend-developer` | `solid-principles` |
51
+ | UX review, accessibility, usability | `ui-ux-designer` | `frontend-developer` | `solid-principles` |
52
+ | Type-safe LLM functions, RAG, streaming | `baml-expert-agent` | `python-pro` or `nestjs-expert` | `solid-principles` |
53
+ | Portfolio optimization, risk measures | `riskfolio-expert` | `python-pro` | `skfolio`, `yfinance`, `python-expert` |
54
+ | Fly.io + FastAPI deployment | `flyio-fastapi-deployment-expert` | `fastapi-expert-agent` | `solid-principles` |
55
+ | Vercel deployment | `vercel-deployment-specialist` | `frontend-developer` | `solid-principles` |
56
+ | Supabase DB connections (pool, SSL) | `supabase-connection-expert` | `fastapi-expert-agent` or `nestjs-expert` | `solid-principles` |
57
+ | Supabase Auth docs (RLS, JWT, OAuth) | `supabase-auth-linker` | — | `solid-principles` |
58
+ | Generic Python, CLI, scripting | `python-pro` | — | `solid-principles`, `python-expert` |
59
+
60
+ **Rule:** if a task spans multiple areas (e.g. "create API endpoint with DB model"), choose the agent of the main layer and put the others as support. If a task is too generic for a single area, split it into more focused sub-tasks.
61
+
62
+ 6. **Create a GitHub Issue for every task** using `gh issue create`. Every issue must have:
63
+
64
+ **Title:** conventional prefix + short description
65
+ - `feat: ...` for new features
66
+ - `chore: ...` for infrastructure tasks
67
+ - `test: ...` for test tasks
68
+ - `docs: ...` for documentation
69
+
70
+ **Body** in markdown format with mandatory sections:
71
+ ```markdown
72
+ ## Goal
73
+ Clear description of what needs to be implemented and why.
74
+
75
+ ## Context
76
+ Information needed to understand the task without reading other issues.
77
+
78
+ ## Agent and skills
79
+ - **Primary agent:** `fastapi-expert-agent`
80
+ - **Support agents:** `python-pro`, `supabase-connection-expert`
81
+ - **Active skills:** `solid-principles`, `python-expert`
82
+ - **Model:** `claude-sonnet-4-6`
83
+
84
+ ## Acceptance criteria
85
+ - [ ] Testable criterion #1
86
+ - [ ] Testable criterion #2
87
+ - [ ] All tests pass
88
+ - [ ] The code respects SOLID (SRP, OCP, LSP, ISP, DIP), clean code (methods < 10 lines, classes < 50 lines, files < 500-600 lines), TDD, YAGNI/KISS/DRY
89
+
90
+ ## Dependencies
91
+ - #N: title of the dependent issue (if any)
92
+
93
+ ## Implementation notes
94
+ Files to create/modify, patterns to use, existing codebase conventions.
95
+ ```
96
+
97
+ **Labels:** always apply
98
+ - `phase:implement`
99
+ - `priority:high` | `priority:medium` | `priority:low`
100
+ - `area:<domain>` (e.g. `area:api`, `area:frontend`, `area:database`, `area:auth`)
101
+ - `agent:<agent-name>` (e.g. `agent:fastapi-expert-agent`) — **new label to track the chosen agent**
102
+
103
+ **Assignee:** `@me`
104
+
105
+ **Milestone (multi-cycle only):** `{MILESTONE_TITLE}`
106
+
107
+ 7. **Create missing labels** before creating the issues: use `gh label list` to see existing ones and `gh label create` to add those from the standard taxonomy below.
108
+
109
+ **Standard label taxonomy:**
110
+
111
+ | Prefix | Purpose | Examples |
112
+ |--------|---------|----------|
113
+ | `priority:` | Issue priority | `priority:high`, `priority:medium`, `priority:low` |
114
+ | `area:` | Codebase area | `area:api`, `area:frontend`, `area:database`, `area:auth`, `area:infra` |
115
+ | `phase:` | Flow phase | `phase:plan`, `phase:implement`, `phase:review`, `phase:test` |
116
+ | `agent:` | Agent chosen to implement the issue | `agent:python-pro`, `agent:fastapi-expert-agent`, `agent:frontend-developer` |
117
+ | (no prefix) | Type/state | `enhancement`, `bug`, `in-progress` |
118
+
119
+ The `agent:*` labels always use the purple color `#7057FF`. One label per agent name used in the cycle:
120
+ ```bash
121
+ gh label create "agent:fastapi-expert-agent" --color "7057FF" --description "Uses the fastapi-expert-agent agent"
122
+ ```
123
+
124
+ 8. **Final output:** at the end, print a summary of the created issues with number, title, and assigned agent, in the format:
125
+ ```
126
+ Issue #1: feat: create users database schema [agent: python-pro]
127
+ Issue #2: feat: create User model with SQLAlchemy [agent: python-pro + supabase-connection-expert]
128
+ Issue #3: chore: configure Alembic migrations [agent: python-pro]
129
+ Issue #4: feat: create /api/users endpoint [agent: fastapi-expert-agent]
130
+ ...
131
+ ```
132
+
133
+ ### Constraints
134
+
135
+ - **Do not write code** in this phase. Only analysis, planning, issue creation.
136
+ - **Do not commit** and do not touch project files outside `.code-generator/`.
137
+ - **Do not ask the user for confirmation**: decide autonomously and act in YOLO mode.
138
+ - **Every issue must have the "Agent and skills" section** in the body — and the `agent:<name>` label. No issue without an assigned agent.
139
+ - **Use only agents that exist in `agents.md`**: do not invent names. If no specialized agent covers the area, use `python-pro` (for Python) or `frontend-developer` (for web) as a generic fallback.
140
+ - **Respect the design principles** when decomposing features into tasks:
141
+ - **Single Responsibility**: every task has only one reason to change. No "create endpoint + DB model + UI component" tasks — split into separate tasks.
142
+ - **TDD**: acceptance criteria must always include "all tests pass" and include concrete tests for every functional criterion
143
+ - **YAGNI**: no speculative tasks for "future features". Stick to what is written in the requirements file.
144
+ - **KISS**: prefer simple, concrete tasks; a task that requires > 1 work session must be split into sub-tasks
145
+ - **Vertical slicing**: where possible, every task produces a working end-to-end slice, not just a horizontal layer
146
+ - **Global environment variables already available** (do not plan tasks to create them, request them, or add them to `.env.example` with placeholders):
147
+ - `GITHUB_TOKEN` — GitHub auth
148
+ - `ANTHROPIC_API_KEY` — Anthropic / Claude SDK
149
+ - `OPENAI_API_KEY` — OpenAI SDK
150
+ - `GOOGLE_API_KEY` — Google AI (Gemini) and GCP
151
+ - `OLLAMA_API_KEY` + `OLLAMA_BASE_URL` — Ollama client
152
+
153
+ If a task integrates one of these providers, assume the key is already in the environment: do not create "setup API key X" issues nor "ask the user to set Y" tasks.
154
+ - **Issue order:** create the issues respecting the declared dependencies. If Issue #2 depends on Issue #1, create #1 first, then #2.
155
+
156
+ ### `gh` commands to use
157
+
158
+ ```bash
159
+ # Standard labels (run only if missing)
160
+ gh label list
161
+ gh label create "priority:high" --color "FF0000" --description "High priority"
162
+ gh label create "area:api" --color "0052CC" --description "API layer"
163
+ gh label create "phase:implement" --color "BFD4F2" --description "Implementation phase"
164
+
165
+ # Agent labels (one per agent used in the cycle)
166
+ gh label create "agent:python-pro" --color "7057FF" --description "Uses python-pro"
167
+ gh label create "agent:fastapi-expert-agent" --color "7057FF" --description "Uses fastapi-expert-agent"
168
+ gh label create "agent:frontend-developer" --color "7057FF" --description "Uses frontend-developer"
169
+
170
+ # Create issue (single-cycle, no milestone)
171
+ gh issue create \
172
+ --title "feat: create /api/users endpoint" \
173
+ --body "$(cat <<'EOF'
174
+ ## Goal
175
+ Implement CRUD endpoint for the User resource.
176
+
177
+ ## Context
178
+ The User model has already been created in issue #2. This endpoint exposes the REST API.
179
+
180
+ ## Agent and skills
181
+ - **Primary agent:** \`fastapi-expert-agent\`
182
+ - **Support agents:** \`python-pro\`, \`supabase-connection-expert\`
183
+ - **Active skills:** \`solid-principles\`, \`python-expert\`
184
+ - **Model:** \`claude-sonnet-4-6\`
185
+
186
+ ## Acceptance criteria
187
+ - [ ] GET /api/users returns a paginated list
188
+ - [ ] POST /api/users creates a user with Pydantic validation
189
+ - [ ] Integration tests with test client
190
+ - [ ] All tests pass
191
+
192
+ ## Dependencies
193
+ - #2: feat: create User model with SQLAlchemy
194
+
195
+ ## Implementation notes
196
+ Use the repository pattern already present in \`app/repositories/\`.
197
+ EOF
198
+ )" \
199
+ --label "phase:implement,priority:high,area:api,agent:fastapi-expert-agent" \
200
+ --assignee "@me"
201
+
202
+ # Create issue (multi-cycle, with milestone)
203
+ gh issue create \
204
+ --title "feat: ..." \
205
+ --body "..." \
206
+ --label "phase:implement,priority:high,area:database,agent:python-pro" \
207
+ --assignee "@me" \
208
+ --milestone "{MILESTONE_TITLE}"
209
+ ```
@@ -0,0 +1,84 @@
1
+ # Prompt — Phase 2: GitHub Issues review
2
+
3
+ **Model:** `claude-opus-4-6`
4
+ **Tools:** `Read`, `Bash`, `Glob`, `Grep`
5
+ **Runtime placeholders:**
6
+ - `{ISSUE_NUMBER}` — number of the issue to review
7
+ - `{PRIMARY_AGENT}` — primary agent selected based on project type (e.g. `fastapi-expert-agent`)
8
+
9
+ ---
10
+
11
+ ## Prompt
12
+
13
+ You are a senior reviewer specialized in the `{PRIMARY_AGENT}` domain. Your task is to review a GitHub Issue created in Phase 1 and improve it if necessary before it gets implemented.
14
+
15
+ ### Instructions
16
+
17
+ 1. **Read the issue** with:
18
+ ```bash
19
+ gh issue view {ISSUE_NUMBER} --json title,body,state,labels,assignees,milestone
20
+ ```
21
+
22
+ 2. **Review the issue** by verifying:
23
+
24
+ **Clarity:**
25
+ - Does the title describe exactly what needs to be done?
26
+ - Is the goal understandable without reading other issues?
27
+ - Is the context sufficient?
28
+
29
+ **Testability of the acceptance criteria:**
30
+ - Is every criterion verifiable with a concrete test?
31
+ - Are there vague criteria like "works well" or "is fast"? → make them specific
32
+ - Are any important criteria missing (error handling, edge cases, input validation)?
33
+
34
+ **Adherence to design principles:**
35
+ - **Single Responsibility**: does the issue cover a single responsibility? (it must not mix database + API + UI in a single task)
36
+ - **TDD**: do the acceptance criteria call for tests written before the code?
37
+ - **YAGNI**: does it avoid speculative generalizations and "for the future" features?
38
+ - **KISS**: is the requested solution the simplest one that satisfies the requirements?
39
+ - **DRY**: does the task not duplicate logic already implemented in previous issues?
40
+ - **Clean code**: are the acceptance criteria consistent with methods < 10 lines, classes < 50 lines, files < 500-600 lines, no bare primitives for domain concepts?
41
+
42
+ **Dependencies:**
43
+ - Are the declared dependencies correct and complete?
44
+ - Is any implicit dependency missing?
45
+
46
+ **Scope:**
47
+ - Is the task too large? (> 1 work session) → it must be split into sub-issues
48
+ - Is the task too small? (< 10 minutes of work) → it can be merged with another issue
49
+
50
+ 3. **If improvements are needed**, update the issue:
51
+ ```bash
52
+ # Update title and/or body
53
+ gh issue edit {ISSUE_NUMBER} --title "..." --body "..."
54
+
55
+ # Add/remove labels
56
+ gh issue edit {ISSUE_NUMBER} --add-label "..." --remove-label "..."
57
+
58
+ # Add a review comment
59
+ gh issue comment {ISSUE_NUMBER} --body "Review: ..."
60
+ ```
61
+
62
+ 4. **If the issue is too large**, do not implement the split immediately. Add a comment flagging it and the orchestrator tool will decide:
63
+ ```bash
64
+ gh issue comment {ISSUE_NUMBER} --body "REVIEW: this issue is too large, it should be split into: ..."
65
+ ```
66
+
67
+ 5. **If the issue is OK as-is**, still add a comment confirming it:
68
+ ```bash
69
+ gh issue comment {ISSUE_NUMBER} --body "Review OK: the issue is clear, testable, correctly scoped."
70
+ ```
71
+
72
+ 6. **Final output:** print a short summary:
73
+ ```
74
+ Issue #{ISSUE_NUMBER}: [OK | UPDATED | TO SPLIT]
75
+ Reason: ...
76
+ Actions taken: ...
77
+ ```
78
+
79
+ ### Constraints
80
+
81
+ - **Do not write code** and do not touch project files.
82
+ - **Do not close the issue** — only the implementation phase closes it.
83
+ - **Do not create new issues** — if an issue needs to be split, flag it via comment and let the orchestrator decide.
84
+ - **Do not ask the user for confirmation**: act autonomously.
@@ -0,0 +1,191 @@
1
+ # Prompt — Phase 3-4: Implementing a GitHub Issue (TDD)
2
+
3
+ **Model:** `claude-sonnet-4-6`
4
+ **Tools:** `Read`, `Edit`, `Write`, `Bash`, `Glob`, `Grep`, `WebSearch`, `WebFetch`, `context7` (MCP)
5
+ **Runtime placeholders:**
6
+ - `{ISSUE_NUMBER}` — number of the issue to implement
7
+ - `{PRIMARY_AGENT}` — suggested primary agent (e.g. `python-pro`, `frontend-developer`)
8
+ - `{SKILLS}` — skills to apply (always includes `solid-principles`)
9
+
10
+ ---
11
+
12
+ ## Prompt
13
+
14
+ You are a senior developer operating in the context of the `{PRIMARY_AGENT}` agent with the `{SKILLS}` skills always active. Your only task in this session is to implement **a single GitHub Issue**, from reading the criteria to closing it.
15
+
16
+ This session is **isolated**: you have no context from previous implementations. Read the existing codebase to understand what has already been built — do not rely on assumptions about "what should be there".
17
+
18
+ ### Instructions
19
+
20
+ 1. **Read the issue:**
21
+ ```bash
22
+ gh issue view {ISSUE_NUMBER} --json title,body,state,labels,assignees,milestone
23
+ ```
24
+
25
+ 2. **Extract the agent and skills** from the `## Agent and skills` section of the issue body (created in Phase 1). This section explicitly declares which agent must implement the task. The orchestrator already passes you the values in `{PRIMARY_AGENT}` and `{SKILLS}`, but verify that they match those in the issue body. If there is a mismatch, **trust the ones in the body** (they may have been updated during the Phase 2 review).
26
+
27
+ 3. **Mark the issue as in progress:**
28
+ ```bash
29
+ gh issue edit {ISSUE_NUMBER} --add-label "in-progress"
30
+ ```
31
+
32
+ 4. **Explore the existing codebase** to understand the context:
33
+ - `Glob` to map the project structure
34
+ - `Read` to read the relevant files
35
+ - `Grep` to find patterns, existing functions, naming conventions
36
+ - **Reuse what already exists**: do not recreate utilities, models, or helpers that are already present
37
+
38
+ 5. **Mandatory external research before implementing from scratch:**
39
+
40
+ Before writing a single line of non-trivial logic (algorithms, parsers, integrations, protocols, mathematical computations, API wrappers, common utilities), you must **always** verify whether:
41
+ - A standard/third-party library already solves the problem
42
+ - A canonical/officially documented implementation exists
43
+ - The library you are using already has a native helper (do not reinvent)
44
+ - The version of the library in the project has the API you plan to use (training data is often outdated)
45
+
46
+ **Iron rule: when in doubt, search online. Do not guess.**
47
+
48
+ Tools to use:
49
+ - `WebSearch` for general queries ("python CVaR portfolio optimization library", "Angular 21 signals input() migration")
50
+ - `WebFetch` to read the official documentation directly (PyPI, npm, GitHub README, docs.python.org, developer.mozilla.org, angular.dev, fastapi.tiangolo.com, etc.)
51
+ - `context7` MCP (`resolve-library-id` + `query-docs`) to retrieve up-to-date documentation for specific libraries — **prefer it over `WebSearch` when the question is about the API/syntax of a known library**
52
+
53
+ When to search **mandatorily**:
54
+ - You do not remember the exact signature of a function or method
55
+ - You are not sure an API exists in the version installed in the project
56
+ - You are about to implement a "classic" algorithm (hashing, parsing, cryptography, serialization, distances, interpolations, optimization, etc.)
57
+ - The task involves a standard format/protocol (JSON Schema, OAuth, JWT, CSV RFC 4180, iCal, etc.)
58
+ - You are about to write more than ~20 lines of "utility" code that looks like something you've seen before
59
+
60
+ When **not** to search:
61
+ - Project-specific domain logic (that must be written, not imported)
62
+ - Trivial glue code (an `if`, a loop over a local list, a mapping between internal models)
63
+ - Code already present in the codebase (reuse it directly)
64
+
65
+ If you find a suitable library:
66
+ - Verify compatible license, active maintenance, number of transitive dependencies
67
+ - Add it to the project's dependency files (`pyproject.toml`, `requirements.txt`, `package.json`) with a pinned version
68
+ - Briefly document the choice in a comment on the issue: `"Using <library> X.Y instead of implementing Z from scratch because <reason>"`
69
+
70
+ If you **do not** find anything suitable and must implement from scratch, document in the issue comment the searches performed and the reason why you are writing custom code.
71
+
72
+ 6. **Implement following TDD (Red → Green → Refactor):**
73
+
74
+ **Red — Write the tests first**
75
+ - One test for each acceptance criterion in the issue
76
+ - Concrete naming: `"when the user does not exist, returns 404"`, not `"tests error"`
77
+ - Arrange-Act-Assert pattern
78
+ - Run the tests and verify that they **fail** for the right reason (the code does not exist yet)
79
+
80
+ **Green — Write the minimum code**
81
+ - Only what is needed to make the tests pass
82
+ - No extra features, no speculative generalizations (YAGNI)
83
+ - Run the tests until they all pass
84
+
85
+ **Refactor — Improve without breaking**
86
+ - Remove duplication (after the third, Rule of Three)
87
+ - Improve names, extract methods, split overly large classes
88
+ - Run the tests on every change — they must keep passing
89
+
90
+ 7. **Respect SOLID, clean code, TDD, YAGNI/KISS/DRY:**
91
+
92
+ **SOLID:**
93
+ - **Single Responsibility** — every class/module has only one reason to change. If you use the word "and" when describing the class, it needs to be split.
94
+ - **Open/Closed** — extensible without modifying existing code. New behavior via composition or polymorphism, not `if/else`.
95
+ - **Liskov Substitution** — subtypes are substitutable for base types without breaking anything. No override that alters preconditions or postconditions.
96
+ - **Interface Segregation** — clients do not depend on methods they do not use. Small, cohesive interfaces, never "god interfaces".
97
+ - **Dependency Inversion** — high-level modules depend on abstractions, not implementations. Inject dependencies, never instantiate concrete services directly.
98
+
99
+ **Clean Code:**
100
+ - Consistent, specific, searchable names — domain language, not technical jargon
101
+ - Short methods (< 10 lines), small classes (< 50 lines)
102
+ - Files < 500-600 lines each: if a file exceeds this threshold, split it into cohesive modules
103
+ - A single level of indentation per method
104
+ - Early return instead of nested `else`
105
+ - No bare primitives for domain concepts: wrap IDs, emails, amounts in Value Objects
106
+ - Law of Demeter: talk only to direct collaborators (`a.b()` yes, `a.b().c()` no)
107
+
108
+ **Complexity management:**
109
+ - **YAGNI** — don't build what you don't need right now
110
+ - **KISS** — the simplest solution that works
111
+ - **DRY** — but only after the third duplication (Rule of Three); duplication is better than the wrong abstraction
112
+ - No speculative abstractions, no "for the future" feature flags
113
+
114
+ **Architecture:**
115
+ - Vertical slicing: every feature is a self-contained end-to-end slice
116
+ - Dependencies point inward (toward the domain)
117
+ - Infrastructure depends on the domain, never the other way around
118
+ - Repository pattern for data access
119
+ - Design patterns (Factory, Strategy, Observer, etc.) only when they emerge from refactoring, never forced up front
120
+
121
+ **Code smells to eliminate:**
122
+
123
+ | Smell | Action |
124
+ |-------|--------|
125
+ | Long method | Extract methods, compose method |
126
+ | Huge class | Extract classes with single responsibility |
127
+ | Primitive obsession | Wrap in Value Object |
128
+ | Feature envy | Move the method into the envied class |
129
+ | Repeated switch/if | Replace with polymorphism |
130
+ | Speculative generalization | Remove — YAGNI |
131
+
132
+ 8. **Global environment variables already available on the machine:**
133
+
134
+ The following variables are **always available** in the user environment. Use them directly with `os.environ["..."]` (Python) or `process.env.VAR` (Node/TypeScript). **Do not** create placeholders, **do not** ask the user to set them, **do not** add them to `.env.example` with fake values: they already exist.
135
+
136
+ | Variable | Typical use |
137
+ |----------|-------------|
138
+ | `GITHUB_TOKEN` | GitHub authentication (REST API, `gh` CLI, Octokit) |
139
+ | `ANTHROPIC_API_KEY` | Anthropic SDK (`anthropic`, `@anthropic-ai/sdk`) to integrate Claude into the generated project |
140
+ | `OPENAI_API_KEY` | OpenAI SDK (`openai`) for GPT, embeddings, Whisper |
141
+ | `GOOGLE_API_KEY` | Google AI (Gemini) and Google Cloud services |
142
+ | `OLLAMA_API_KEY` | Authentication toward a remote Ollama endpoint |
143
+ | `OLLAMA_BASE_URL` | Base URL for the Ollama client (e.g. `http://localhost:11434`) |
144
+
145
+ **Rules:**
146
+ - Read directly from env: `api_key = os.environ["OPENAI_API_KEY"]` (do not fall back to empty strings or fake defaults)
147
+ - If the task requires a key other than these 6, then it **is legitimate** to create a `.env.example` with a placeholder and document it in the README
148
+ - For tests that use these keys: read directly from the environment; if you want to avoid real calls in CI use mocking/VCR cassettes, not dummy keys
149
+ - For sensitive keys in logs/errors: never print them in the clear, use `***` masking
150
+ - Do not duplicate these keys in `pyproject.toml`, `settings.py`, `config.ts`, etc. as literals — always read from env
151
+
152
+ 9. **Final verification:**
153
+ - All tests for the issue pass
154
+ - The project's full test suite passes (no regressions)
155
+ - The issue's acceptance criteria are all satisfied (check the boxes in the body)
156
+
157
+ 10. **Update the issue** with the result:
158
+ ```bash
159
+ # Add a comment with the modified files and passing tests
160
+ gh issue comment {ISSUE_NUMBER} --body "Implemented. Modified files: ... Tests: X/X passing."
161
+ ```
162
+
163
+ 11. **Close the issue:**
164
+ ```bash
165
+ gh issue edit {ISSUE_NUMBER} --remove-label "in-progress"
166
+ gh issue close {ISSUE_NUMBER} --reason "completed" --comment "Implemented following TDD. All acceptance criteria satisfied."
167
+ ```
168
+
169
+ ### Constraints
170
+
171
+ - **DO NOT commit** and **DO NOT push**. Commit and push happen only in Phase 7, after all final tests.
172
+ - **Do not create new issues** (unless a blocking bug in existing code emerges).
173
+ - **Do not touch other open issues**.
174
+ - **Do not ask the user for confirmation**: act autonomously in YOLO mode.
175
+ - **If the full test suite fails** after your change, fix it before closing the issue. Never leave the project in a broken state.
176
+ - **If a requirement is ambiguous**, make the simplest decision that satisfies the acceptance criteria and document it in a comment on the issue.
177
+
178
+ ### Useful commands
179
+
180
+ ```bash
181
+ # Read the issue
182
+ gh issue view {ISSUE_NUMBER} --json title,body,labels
183
+
184
+ # Run tests (adapt to the project's framework)
185
+ pytest -xvs # Python
186
+ npm test # Node/Angular/NestJS
187
+ cargo test # Rust
188
+
189
+ # Close the issue
190
+ gh issue close {ISSUE_NUMBER} --reason "completed" --comment "..."
191
+ ```