claude-code-generator 0.1.0__tar.gz

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 (78) hide show
  1. claude_code_generator-0.1.0/LICENSE +21 -0
  2. claude_code_generator-0.1.0/PKG-INFO +176 -0
  3. claude_code_generator-0.1.0/README.md +145 -0
  4. claude_code_generator-0.1.0/pyproject.toml +71 -0
  5. claude_code_generator-0.1.0/setup.cfg +4 -0
  6. claude_code_generator-0.1.0/src/claude_code_generator.egg-info/PKG-INFO +176 -0
  7. claude_code_generator-0.1.0/src/claude_code_generator.egg-info/SOURCES.txt +76 -0
  8. claude_code_generator-0.1.0/src/claude_code_generator.egg-info/dependency_links.txt +1 -0
  9. claude_code_generator-0.1.0/src/claude_code_generator.egg-info/entry_points.txt +2 -0
  10. claude_code_generator-0.1.0/src/claude_code_generator.egg-info/requires.txt +8 -0
  11. claude_code_generator-0.1.0/src/claude_code_generator.egg-info/top_level.txt +1 -0
  12. claude_code_generator-0.1.0/src/code_generator/__init__.py +3 -0
  13. claude_code_generator-0.1.0/src/code_generator/agents.py +177 -0
  14. claude_code_generator-0.1.0/src/code_generator/cli.py +49 -0
  15. claude_code_generator-0.1.0/src/code_generator/commands/__init__.py +1 -0
  16. claude_code_generator-0.1.0/src/code_generator/commands/generate.py +252 -0
  17. claude_code_generator-0.1.0/src/code_generator/commands/init.py +72 -0
  18. claude_code_generator-0.1.0/src/code_generator/commands/review.py +117 -0
  19. claude_code_generator-0.1.0/src/code_generator/commands/status.py +83 -0
  20. claude_code_generator-0.1.0/src/code_generator/env.py +55 -0
  21. claude_code_generator-0.1.0/src/code_generator/gh.py +331 -0
  22. claude_code_generator-0.1.0/src/code_generator/logging_setup.py +73 -0
  23. claude_code_generator-0.1.0/src/code_generator/orchestrator/__init__.py +4 -0
  24. claude_code_generator-0.1.0/src/code_generator/orchestrator/cycle_loop.py +371 -0
  25. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase0_complexity.py +159 -0
  26. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase1_plan.py +170 -0
  27. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase2_review.py +126 -0
  28. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase3_4_implement.py +164 -0
  29. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase5_closure.py +154 -0
  30. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase6_test.py +98 -0
  31. claude_code_generator-0.1.0/src/code_generator/orchestrator/phase7_commit.py +167 -0
  32. claude_code_generator-0.1.0/src/code_generator/prompts/__init__.py +86 -0
  33. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-0-complexity.md +85 -0
  34. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-1-planning.md +209 -0
  35. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-2-issue-review.md +84 -0
  36. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-3-implementation.md +191 -0
  37. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-5-final-review.md +135 -0
  38. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-6-test.md +102 -0
  39. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-phase-7-commit.md +103 -0
  40. claude_code_generator-0.1.0/src/code_generator/prompts/prompt-review.md +124 -0
  41. claude_code_generator-0.1.0/src/code_generator/runner/__init__.py +26 -0
  42. claude_code_generator-0.1.0/src/code_generator/runner/rate_limit.py +113 -0
  43. claude_code_generator-0.1.0/src/code_generator/runner/retry.py +165 -0
  44. claude_code_generator-0.1.0/src/code_generator/runner/sdk_runner.py +267 -0
  45. claude_code_generator-0.1.0/src/code_generator/runner/subprocess_runner.py +200 -0
  46. claude_code_generator-0.1.0/src/code_generator/state.py +178 -0
  47. claude_code_generator-0.1.0/src/code_generator/templates/__init__.py +1 -0
  48. claude_code_generator-0.1.0/src/code_generator/templates/angular.md +12 -0
  49. claude_code_generator-0.1.0/src/code_generator/templates/base.md +28 -0
  50. claude_code_generator-0.1.0/src/code_generator/templates/fastapi.md +12 -0
  51. claude_code_generator-0.1.0/src/code_generator/templates/finance.md +9 -0
  52. claude_code_generator-0.1.0/src/code_generator/templates/fullstack.md +24 -0
  53. claude_code_generator-0.1.0/src/code_generator/templates/nestjs.md +9 -0
  54. claude_code_generator-0.1.0/src/code_generator/templates/python-cli.md +9 -0
  55. claude_code_generator-0.1.0/tests/test_agents.py +385 -0
  56. claude_code_generator-0.1.0/tests/test_cycle_loop.py +573 -0
  57. claude_code_generator-0.1.0/tests/test_env.py +138 -0
  58. claude_code_generator-0.1.0/tests/test_generate.py +180 -0
  59. claude_code_generator-0.1.0/tests/test_generate_resume.py +436 -0
  60. claude_code_generator-0.1.0/tests/test_gh.py +365 -0
  61. claude_code_generator-0.1.0/tests/test_init.py +140 -0
  62. claude_code_generator-0.1.0/tests/test_logging_setup.py +81 -0
  63. claude_code_generator-0.1.0/tests/test_phase0.py +175 -0
  64. claude_code_generator-0.1.0/tests/test_phase1.py +223 -0
  65. claude_code_generator-0.1.0/tests/test_phase2.py +224 -0
  66. claude_code_generator-0.1.0/tests/test_phase3_4.py +229 -0
  67. claude_code_generator-0.1.0/tests/test_phase5.py +200 -0
  68. claude_code_generator-0.1.0/tests/test_phase6.py +137 -0
  69. claude_code_generator-0.1.0/tests/test_phase7.py +257 -0
  70. claude_code_generator-0.1.0/tests/test_prompts.py +185 -0
  71. claude_code_generator-0.1.0/tests/test_rate_limit.py +260 -0
  72. claude_code_generator-0.1.0/tests/test_retry.py +252 -0
  73. claude_code_generator-0.1.0/tests/test_review.py +156 -0
  74. claude_code_generator-0.1.0/tests/test_sdk_runner.py +285 -0
  75. claude_code_generator-0.1.0/tests/test_state.py +224 -0
  76. claude_code_generator-0.1.0/tests/test_status.py +106 -0
  77. claude_code_generator-0.1.0/tests/test_subprocess_runner.py +213 -0
  78. claude_code_generator-0.1.0/tests/test_version.py +29 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Silvio Baratto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: claude-code-generator
3
+ Version: 0.1.0
4
+ Summary: Orchestrator CLI that drives Claude Code end-to-end to generate whole projects from a requirements.md file.
5
+ Author: Silvio Baratto
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/SilvioBaratto/code-generator
8
+ Project-URL: Repository, https://github.com/SilvioBaratto/code-generator
9
+ Project-URL: Issues, https://github.com/SilvioBaratto/code-generator/issues
10
+ Keywords: claude,claude-code,code-generation,llm,cli,orchestrator
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Code Generators
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: claude-agent-sdk
24
+ Requires-Dist: typer
25
+ Requires-Dist: rich
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: pytest-asyncio; extra == "dev"
29
+ Requires-Dist: ruff; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # code-generator
33
+
34
+ A Python CLI that orchestrates Claude Code end-to-end to generate a whole project from a `requirements.md` file. Three commands — `init`, `generate`, `review` — plus `status`. Works for any project type: Python CLI, FastAPI, Angular, NestJS, full-stack, finance, BAML/LLM.
35
+
36
+ > **Max subscription only.** This tool uses **exclusively** the Claude Max subscription. It strips every environment variable that could route a call through the API and aborts on startup if any are still present. There is no path to API credit billing — see [Safety constraints](#safety-constraints) below.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pipx install code-generator # recommended
42
+ # or
43
+ pip install code-generator # user-site
44
+ # or, from source
45
+ git clone git@github.com:SilvioBaratto/code-generator.git
46
+ cd code-generator && pip install -e ".[dev]"
47
+ ```
48
+
49
+ ## Authentication
50
+
51
+ ```bash
52
+ # Claude Code (Max subscription)
53
+ claude auth login
54
+
55
+ # GitHub (SSH protocol)
56
+ gh auth login -h github.com -p ssh
57
+ gh config set git_protocol ssh
58
+ ```
59
+
60
+ ## Commands
61
+
62
+ ### `code-generator init [--template TYPE] [--force]`
63
+
64
+ Scaffold `.code-generator/` in the current directory with a ready-to-fill `requirements.md`. Templates: `fastapi`, `angular`, `nestjs`, `fullstack`, `python-cli`, `finance`. Refuses to clobber an existing `.code-generator/` without `--force`.
65
+
66
+ ```bash
67
+ code-generator init --template fastapi
68
+ $EDITOR .code-generator/requirements.md
69
+ ```
70
+
71
+ ### `code-generator generate [flags]`
72
+
73
+ Read `.code-generator/requirements.md` and orchestrate Claude Code through the 0→7 phase pipeline:
74
+
75
+ | Phase | Action | Model |
76
+ |---|---|---|
77
+ | 0 | Complexity analysis (single vs multi-cycle) | Opus 4.6 |
78
+ | 1 | Planning — creates GitHub issues + milestone | Opus 4.6 |
79
+ | 2 | Per-issue review | Opus 4.6 |
80
+ | 3-4 | Implementation, fresh SDK session per issue (TDD) | Sonnet 4.6 |
81
+ | 5 | Closure + cross-module review | Opus 4.6 |
82
+ | 6 | Test suite, max 3 retries on failure | Sonnet 4.6 |
83
+ | 7 | Commit message + git add/commit/push | Haiku 4.5 |
84
+
85
+ Flags:
86
+
87
+ | Flag | Description | Default |
88
+ |---|---|---|
89
+ | `--dry-run` | Run only Phase 0 + Phase 1 (planning) | false |
90
+ | `--phase N` | Resume from phase N | — |
91
+ | `--continue` | Resume from the last completed phase (reads `state.json`) | false |
92
+ | `--mode auto\|single\|multi-cycle` | Force a mode (default `auto` runs Phase 0 first) | auto |
93
+ | `--cycle N` | Resume from cycle N (multi-cycle only) | — |
94
+
95
+ In multi-cycle mode each cycle is a GitHub Milestone and produces a committable, working increment. Each cycle starts a fresh SDK session and re-reads the committed codebase, so the model never relies on stale conversational context.
96
+
97
+ If the Max subscription hits a rate limit, the tool **pauses** — it persists the session id and `paused_until` timestamp atomically to `.code-generator/state.json`, sleeps until the window resets, and resumes with `--resume <session_id>`. A killed process will resume on its own when re-run.
98
+
99
+ ### `code-generator review [--create-issues] [--severity LEVEL]`
100
+
101
+ Run a standalone Opus 4.6 review of the current codebase against the design principles in `requirements.md` §4 (SOLID, Clean Code, TDD, YAGNI/KISS/DRY). With `--create-issues`, every finding becomes a GitHub Issue.
102
+
103
+ ### `code-generator status`
104
+
105
+ Print a Rich table with the current mode, current cycle, current phase, open/closed issue counts, the rate-limit pause state (with minutes remaining if paused), and the last error.
106
+
107
+ ## Safety constraints
108
+
109
+ The tool enforces eight non-negotiables (see `CLAUDE.md` for the full list):
110
+
111
+ 1. **Max subscription only, zero API credits.** Before any SDK or subprocess call, the tool strips `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BEDROCK_API_KEY`, `ANTHROPIC_VERTEX_PROJECT_ID`, `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX` from the environment. A startup check refuses to run if any are present.
112
+ 2. **Never `--bare`.** The CLI flag `--bare` skips OAuth and forces API credits — it is **never** passed by this tool. If Anthropic ever makes `--bare` the default for `claude -p`, pin the CLI version or pass the opposite flag explicitly.
113
+ 3. **YOLO mode always.** Every SDK call uses `permission_mode="bypassPermissions"`; the subprocess fallback uses `--dangerously-skip-permissions`.
114
+ 4. **Overage protection.** On every `RateLimitEvent`, the tool checks `info.overage_status` and aborts immediately if it is anything other than `None` or `"disabled"`. Reference incident: [anthropics/claude-code#37686](https://github.com/anthropics/claude-code/issues/37686) — a user burned $1,800 in two days because billing overage was silently enabled.
115
+ 5. **Wait-and-resume rate-limit handling.** Rate limits are not retried with exponential backoff — the tool sleeps until `resets_at + 60s` and resumes the same session. Backoff (10→20→40→80→120s) only applies to non-rate-limit transient errors.
116
+ 6. **Fresh SDK session per issue.** The implementation phase never reuses conversational context across issues — each issue is a `/clear`-equivalent fresh session.
117
+ 7. **Atomic state writes.** `.code-generator/state.json` is updated via `tmp → os.replace(tmp, STATE)` so a crash mid-write cannot corrupt it.
118
+ 8. **Fixed model per phase.** Opus 4.6 for phases 0/1/2/5; Sonnet 4.6 for phases 3/4/6; Haiku 4.5 for phase 7's commit message.
119
+
120
+ ## Troubleshooting
121
+
122
+ **Startup fails with "dangerous environment variables present".** A previous shell session exported `ANTHROPIC_API_KEY` (or another billing-routing variable). `unset` it and try again — the tool is intentionally strict so a stray export never costs you money.
123
+
124
+ **Rate limit reached.** Run `code-generator status` to see how many minutes remain on the current pause. The next `code-generator generate --continue` will wait out the rest of the window and resume the same session automatically.
125
+
126
+ **`gh issue create` fails.** Confirm `gh auth status` reports an authenticated SSH session for `github.com`, and that the current directory is inside a repo with a default remote configured.
127
+
128
+ **Tests don't pass after Phase 6.** The orchestrator skips Phase 7 (commit) when the test runner reports persistent failures. Fix the failing tests manually, then run `code-generator generate --continue` to re-enter from where it stopped.
129
+
130
+ ## Project layout
131
+
132
+ ```
133
+ src/code_generator/
134
+ ├── cli.py # Typer entry point: init, generate, review, status
135
+ ├── env.py # DANGEROUS_VARS, build_agent_env, assert_safe_environment
136
+ ├── state.py # State dataclasses + atomic load/save
137
+ ├── prompts/ # Packaged prompt-phase-*.md files + load_prompt
138
+ ├── templates/ # Project templates for `init`
139
+ ├── logging_setup.py # Per-phase log files under .code-generator/logs/
140
+ ├── gh.py # Subprocess wrapper for issues, milestones, labels
141
+ ├── agents.py # Tech-stack detector + agent selection matrix
142
+ ├── runner/
143
+ │ ├── sdk_runner.py # claude-agent-sdk wrapper, RateLimitEvent handling
144
+ │ ├── subprocess_runner.py # CLI fallback, stream-json parser
145
+ │ ├── rate_limit.py # Wait-and-resume main loop
146
+ │ └── retry.py # Backoff + circuit breaker
147
+ ├── orchestrator/
148
+ │ ├── phase0_complexity.py # single vs multi-cycle decision
149
+ │ ├── phase1_plan.py # milestone + issues
150
+ │ ├── phase2_review.py # per-issue review
151
+ │ ├── phase3_4_implement.py # TDD loop, fresh session per issue
152
+ │ ├── phase5_closure.py # closure + fix-issue feedback loop
153
+ │ ├── phase6_test.py # test runner, max 3 retries
154
+ │ ├── phase7_commit.py # Haiku commit message + push with rebase retry
155
+ │ └── cycle_loop.py # multi-cycle driver
156
+ └── commands/ # init, status, generate, review (Typer commands)
157
+ ```
158
+
159
+ ## Development
160
+
161
+ ```bash
162
+ git clone git@github.com:SilvioBaratto/code-generator.git
163
+ cd code-generator
164
+ python -m venv .venv && source .venv/bin/activate
165
+ pip install -e ".[dev]"
166
+ pytest -q
167
+ ruff check src tests
168
+ ```
169
+
170
+ ## Reference
171
+
172
+ The full specification lives in [`requirements.md`](requirements.md). Each prompt file (`prompt-phase-*.md`, `prompt-review.md`) is loaded verbatim by the orchestrator with `{NAME}` placeholders substituted at runtime — edit the prompts there, not inline in Python.
173
+
174
+ ## License
175
+
176
+ MIT.
@@ -0,0 +1,145 @@
1
+ # code-generator
2
+
3
+ A Python CLI that orchestrates Claude Code end-to-end to generate a whole project from a `requirements.md` file. Three commands — `init`, `generate`, `review` — plus `status`. Works for any project type: Python CLI, FastAPI, Angular, NestJS, full-stack, finance, BAML/LLM.
4
+
5
+ > **Max subscription only.** This tool uses **exclusively** the Claude Max subscription. It strips every environment variable that could route a call through the API and aborts on startup if any are still present. There is no path to API credit billing — see [Safety constraints](#safety-constraints) below.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pipx install code-generator # recommended
11
+ # or
12
+ pip install code-generator # user-site
13
+ # or, from source
14
+ git clone git@github.com:SilvioBaratto/code-generator.git
15
+ cd code-generator && pip install -e ".[dev]"
16
+ ```
17
+
18
+ ## Authentication
19
+
20
+ ```bash
21
+ # Claude Code (Max subscription)
22
+ claude auth login
23
+
24
+ # GitHub (SSH protocol)
25
+ gh auth login -h github.com -p ssh
26
+ gh config set git_protocol ssh
27
+ ```
28
+
29
+ ## Commands
30
+
31
+ ### `code-generator init [--template TYPE] [--force]`
32
+
33
+ Scaffold `.code-generator/` in the current directory with a ready-to-fill `requirements.md`. Templates: `fastapi`, `angular`, `nestjs`, `fullstack`, `python-cli`, `finance`. Refuses to clobber an existing `.code-generator/` without `--force`.
34
+
35
+ ```bash
36
+ code-generator init --template fastapi
37
+ $EDITOR .code-generator/requirements.md
38
+ ```
39
+
40
+ ### `code-generator generate [flags]`
41
+
42
+ Read `.code-generator/requirements.md` and orchestrate Claude Code through the 0→7 phase pipeline:
43
+
44
+ | Phase | Action | Model |
45
+ |---|---|---|
46
+ | 0 | Complexity analysis (single vs multi-cycle) | Opus 4.6 |
47
+ | 1 | Planning — creates GitHub issues + milestone | Opus 4.6 |
48
+ | 2 | Per-issue review | Opus 4.6 |
49
+ | 3-4 | Implementation, fresh SDK session per issue (TDD) | Sonnet 4.6 |
50
+ | 5 | Closure + cross-module review | Opus 4.6 |
51
+ | 6 | Test suite, max 3 retries on failure | Sonnet 4.6 |
52
+ | 7 | Commit message + git add/commit/push | Haiku 4.5 |
53
+
54
+ Flags:
55
+
56
+ | Flag | Description | Default |
57
+ |---|---|---|
58
+ | `--dry-run` | Run only Phase 0 + Phase 1 (planning) | false |
59
+ | `--phase N` | Resume from phase N | — |
60
+ | `--continue` | Resume from the last completed phase (reads `state.json`) | false |
61
+ | `--mode auto\|single\|multi-cycle` | Force a mode (default `auto` runs Phase 0 first) | auto |
62
+ | `--cycle N` | Resume from cycle N (multi-cycle only) | — |
63
+
64
+ In multi-cycle mode each cycle is a GitHub Milestone and produces a committable, working increment. Each cycle starts a fresh SDK session and re-reads the committed codebase, so the model never relies on stale conversational context.
65
+
66
+ If the Max subscription hits a rate limit, the tool **pauses** — it persists the session id and `paused_until` timestamp atomically to `.code-generator/state.json`, sleeps until the window resets, and resumes with `--resume <session_id>`. A killed process will resume on its own when re-run.
67
+
68
+ ### `code-generator review [--create-issues] [--severity LEVEL]`
69
+
70
+ Run a standalone Opus 4.6 review of the current codebase against the design principles in `requirements.md` §4 (SOLID, Clean Code, TDD, YAGNI/KISS/DRY). With `--create-issues`, every finding becomes a GitHub Issue.
71
+
72
+ ### `code-generator status`
73
+
74
+ Print a Rich table with the current mode, current cycle, current phase, open/closed issue counts, the rate-limit pause state (with minutes remaining if paused), and the last error.
75
+
76
+ ## Safety constraints
77
+
78
+ The tool enforces eight non-negotiables (see `CLAUDE.md` for the full list):
79
+
80
+ 1. **Max subscription only, zero API credits.** Before any SDK or subprocess call, the tool strips `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BEDROCK_API_KEY`, `ANTHROPIC_VERTEX_PROJECT_ID`, `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX` from the environment. A startup check refuses to run if any are present.
81
+ 2. **Never `--bare`.** The CLI flag `--bare` skips OAuth and forces API credits — it is **never** passed by this tool. If Anthropic ever makes `--bare` the default for `claude -p`, pin the CLI version or pass the opposite flag explicitly.
82
+ 3. **YOLO mode always.** Every SDK call uses `permission_mode="bypassPermissions"`; the subprocess fallback uses `--dangerously-skip-permissions`.
83
+ 4. **Overage protection.** On every `RateLimitEvent`, the tool checks `info.overage_status` and aborts immediately if it is anything other than `None` or `"disabled"`. Reference incident: [anthropics/claude-code#37686](https://github.com/anthropics/claude-code/issues/37686) — a user burned $1,800 in two days because billing overage was silently enabled.
84
+ 5. **Wait-and-resume rate-limit handling.** Rate limits are not retried with exponential backoff — the tool sleeps until `resets_at + 60s` and resumes the same session. Backoff (10→20→40→80→120s) only applies to non-rate-limit transient errors.
85
+ 6. **Fresh SDK session per issue.** The implementation phase never reuses conversational context across issues — each issue is a `/clear`-equivalent fresh session.
86
+ 7. **Atomic state writes.** `.code-generator/state.json` is updated via `tmp → os.replace(tmp, STATE)` so a crash mid-write cannot corrupt it.
87
+ 8. **Fixed model per phase.** Opus 4.6 for phases 0/1/2/5; Sonnet 4.6 for phases 3/4/6; Haiku 4.5 for phase 7's commit message.
88
+
89
+ ## Troubleshooting
90
+
91
+ **Startup fails with "dangerous environment variables present".** A previous shell session exported `ANTHROPIC_API_KEY` (or another billing-routing variable). `unset` it and try again — the tool is intentionally strict so a stray export never costs you money.
92
+
93
+ **Rate limit reached.** Run `code-generator status` to see how many minutes remain on the current pause. The next `code-generator generate --continue` will wait out the rest of the window and resume the same session automatically.
94
+
95
+ **`gh issue create` fails.** Confirm `gh auth status` reports an authenticated SSH session for `github.com`, and that the current directory is inside a repo with a default remote configured.
96
+
97
+ **Tests don't pass after Phase 6.** The orchestrator skips Phase 7 (commit) when the test runner reports persistent failures. Fix the failing tests manually, then run `code-generator generate --continue` to re-enter from where it stopped.
98
+
99
+ ## Project layout
100
+
101
+ ```
102
+ src/code_generator/
103
+ ├── cli.py # Typer entry point: init, generate, review, status
104
+ ├── env.py # DANGEROUS_VARS, build_agent_env, assert_safe_environment
105
+ ├── state.py # State dataclasses + atomic load/save
106
+ ├── prompts/ # Packaged prompt-phase-*.md files + load_prompt
107
+ ├── templates/ # Project templates for `init`
108
+ ├── logging_setup.py # Per-phase log files under .code-generator/logs/
109
+ ├── gh.py # Subprocess wrapper for issues, milestones, labels
110
+ ├── agents.py # Tech-stack detector + agent selection matrix
111
+ ├── runner/
112
+ │ ├── sdk_runner.py # claude-agent-sdk wrapper, RateLimitEvent handling
113
+ │ ├── subprocess_runner.py # CLI fallback, stream-json parser
114
+ │ ├── rate_limit.py # Wait-and-resume main loop
115
+ │ └── retry.py # Backoff + circuit breaker
116
+ ├── orchestrator/
117
+ │ ├── phase0_complexity.py # single vs multi-cycle decision
118
+ │ ├── phase1_plan.py # milestone + issues
119
+ │ ├── phase2_review.py # per-issue review
120
+ │ ├── phase3_4_implement.py # TDD loop, fresh session per issue
121
+ │ ├── phase5_closure.py # closure + fix-issue feedback loop
122
+ │ ├── phase6_test.py # test runner, max 3 retries
123
+ │ ├── phase7_commit.py # Haiku commit message + push with rebase retry
124
+ │ └── cycle_loop.py # multi-cycle driver
125
+ └── commands/ # init, status, generate, review (Typer commands)
126
+ ```
127
+
128
+ ## Development
129
+
130
+ ```bash
131
+ git clone git@github.com:SilvioBaratto/code-generator.git
132
+ cd code-generator
133
+ python -m venv .venv && source .venv/bin/activate
134
+ pip install -e ".[dev]"
135
+ pytest -q
136
+ ruff check src tests
137
+ ```
138
+
139
+ ## Reference
140
+
141
+ The full specification lives in [`requirements.md`](requirements.md). Each prompt file (`prompt-phase-*.md`, `prompt-review.md`) is loaded verbatim by the orchestrator with `{NAME}` placeholders substituted at runtime — edit the prompts there, not inline in Python.
142
+
143
+ ## License
144
+
145
+ MIT.
@@ -0,0 +1,71 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "claude-code-generator"
7
+ version = "0.1.0"
8
+ description = "Orchestrator CLI that drives Claude Code end-to-end to generate whole projects from a requirements.md file."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Silvio Baratto" }]
12
+ keywords = ["claude", "claude-code", "code-generation", "llm", "cli", "orchestrator"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Code Generators",
23
+ ]
24
+ requires-python = ">=3.11"
25
+ dependencies = [
26
+ "claude-agent-sdk",
27
+ "typer",
28
+ "rich",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/SilvioBaratto/code-generator"
33
+ Repository = "https://github.com/SilvioBaratto/code-generator"
34
+ Issues = "https://github.com/SilvioBaratto/code-generator/issues"
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest",
39
+ "pytest-asyncio",
40
+ "ruff",
41
+ ]
42
+
43
+ [project.scripts]
44
+ code-generator = "code_generator.cli:app"
45
+
46
+ [tool.setuptools]
47
+ package-dir = {"" = "src"}
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["src"]
51
+
52
+ [tool.setuptools.package-data]
53
+ code_generator = [
54
+ "prompts/*.md",
55
+ "templates/*.md",
56
+ ]
57
+
58
+ [tool.ruff]
59
+ line-length = 100
60
+ target-version = "py311"
61
+
62
+ [tool.ruff.lint]
63
+ select = ["E", "F", "I", "UP", "B", "SIM", "TCH"]
64
+ ignore = []
65
+
66
+ [tool.ruff.lint.per-file-ignores]
67
+ "tests/**/*.py" = ["E501", "SIM117", "TC003"]
68
+
69
+ [tool.pytest.ini_options]
70
+ testpaths = ["tests"]
71
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: claude-code-generator
3
+ Version: 0.1.0
4
+ Summary: Orchestrator CLI that drives Claude Code end-to-end to generate whole projects from a requirements.md file.
5
+ Author: Silvio Baratto
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/SilvioBaratto/code-generator
8
+ Project-URL: Repository, https://github.com/SilvioBaratto/code-generator
9
+ Project-URL: Issues, https://github.com/SilvioBaratto/code-generator/issues
10
+ Keywords: claude,claude-code,code-generation,llm,cli,orchestrator
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Code Generators
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: claude-agent-sdk
24
+ Requires-Dist: typer
25
+ Requires-Dist: rich
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: pytest-asyncio; extra == "dev"
29
+ Requires-Dist: ruff; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # code-generator
33
+
34
+ A Python CLI that orchestrates Claude Code end-to-end to generate a whole project from a `requirements.md` file. Three commands — `init`, `generate`, `review` — plus `status`. Works for any project type: Python CLI, FastAPI, Angular, NestJS, full-stack, finance, BAML/LLM.
35
+
36
+ > **Max subscription only.** This tool uses **exclusively** the Claude Max subscription. It strips every environment variable that could route a call through the API and aborts on startup if any are still present. There is no path to API credit billing — see [Safety constraints](#safety-constraints) below.
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ pipx install code-generator # recommended
42
+ # or
43
+ pip install code-generator # user-site
44
+ # or, from source
45
+ git clone git@github.com:SilvioBaratto/code-generator.git
46
+ cd code-generator && pip install -e ".[dev]"
47
+ ```
48
+
49
+ ## Authentication
50
+
51
+ ```bash
52
+ # Claude Code (Max subscription)
53
+ claude auth login
54
+
55
+ # GitHub (SSH protocol)
56
+ gh auth login -h github.com -p ssh
57
+ gh config set git_protocol ssh
58
+ ```
59
+
60
+ ## Commands
61
+
62
+ ### `code-generator init [--template TYPE] [--force]`
63
+
64
+ Scaffold `.code-generator/` in the current directory with a ready-to-fill `requirements.md`. Templates: `fastapi`, `angular`, `nestjs`, `fullstack`, `python-cli`, `finance`. Refuses to clobber an existing `.code-generator/` without `--force`.
65
+
66
+ ```bash
67
+ code-generator init --template fastapi
68
+ $EDITOR .code-generator/requirements.md
69
+ ```
70
+
71
+ ### `code-generator generate [flags]`
72
+
73
+ Read `.code-generator/requirements.md` and orchestrate Claude Code through the 0→7 phase pipeline:
74
+
75
+ | Phase | Action | Model |
76
+ |---|---|---|
77
+ | 0 | Complexity analysis (single vs multi-cycle) | Opus 4.6 |
78
+ | 1 | Planning — creates GitHub issues + milestone | Opus 4.6 |
79
+ | 2 | Per-issue review | Opus 4.6 |
80
+ | 3-4 | Implementation, fresh SDK session per issue (TDD) | Sonnet 4.6 |
81
+ | 5 | Closure + cross-module review | Opus 4.6 |
82
+ | 6 | Test suite, max 3 retries on failure | Sonnet 4.6 |
83
+ | 7 | Commit message + git add/commit/push | Haiku 4.5 |
84
+
85
+ Flags:
86
+
87
+ | Flag | Description | Default |
88
+ |---|---|---|
89
+ | `--dry-run` | Run only Phase 0 + Phase 1 (planning) | false |
90
+ | `--phase N` | Resume from phase N | — |
91
+ | `--continue` | Resume from the last completed phase (reads `state.json`) | false |
92
+ | `--mode auto\|single\|multi-cycle` | Force a mode (default `auto` runs Phase 0 first) | auto |
93
+ | `--cycle N` | Resume from cycle N (multi-cycle only) | — |
94
+
95
+ In multi-cycle mode each cycle is a GitHub Milestone and produces a committable, working increment. Each cycle starts a fresh SDK session and re-reads the committed codebase, so the model never relies on stale conversational context.
96
+
97
+ If the Max subscription hits a rate limit, the tool **pauses** — it persists the session id and `paused_until` timestamp atomically to `.code-generator/state.json`, sleeps until the window resets, and resumes with `--resume <session_id>`. A killed process will resume on its own when re-run.
98
+
99
+ ### `code-generator review [--create-issues] [--severity LEVEL]`
100
+
101
+ Run a standalone Opus 4.6 review of the current codebase against the design principles in `requirements.md` §4 (SOLID, Clean Code, TDD, YAGNI/KISS/DRY). With `--create-issues`, every finding becomes a GitHub Issue.
102
+
103
+ ### `code-generator status`
104
+
105
+ Print a Rich table with the current mode, current cycle, current phase, open/closed issue counts, the rate-limit pause state (with minutes remaining if paused), and the last error.
106
+
107
+ ## Safety constraints
108
+
109
+ The tool enforces eight non-negotiables (see `CLAUDE.md` for the full list):
110
+
111
+ 1. **Max subscription only, zero API credits.** Before any SDK or subprocess call, the tool strips `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BEDROCK_API_KEY`, `ANTHROPIC_VERTEX_PROJECT_ID`, `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX` from the environment. A startup check refuses to run if any are present.
112
+ 2. **Never `--bare`.** The CLI flag `--bare` skips OAuth and forces API credits — it is **never** passed by this tool. If Anthropic ever makes `--bare` the default for `claude -p`, pin the CLI version or pass the opposite flag explicitly.
113
+ 3. **YOLO mode always.** Every SDK call uses `permission_mode="bypassPermissions"`; the subprocess fallback uses `--dangerously-skip-permissions`.
114
+ 4. **Overage protection.** On every `RateLimitEvent`, the tool checks `info.overage_status` and aborts immediately if it is anything other than `None` or `"disabled"`. Reference incident: [anthropics/claude-code#37686](https://github.com/anthropics/claude-code/issues/37686) — a user burned $1,800 in two days because billing overage was silently enabled.
115
+ 5. **Wait-and-resume rate-limit handling.** Rate limits are not retried with exponential backoff — the tool sleeps until `resets_at + 60s` and resumes the same session. Backoff (10→20→40→80→120s) only applies to non-rate-limit transient errors.
116
+ 6. **Fresh SDK session per issue.** The implementation phase never reuses conversational context across issues — each issue is a `/clear`-equivalent fresh session.
117
+ 7. **Atomic state writes.** `.code-generator/state.json` is updated via `tmp → os.replace(tmp, STATE)` so a crash mid-write cannot corrupt it.
118
+ 8. **Fixed model per phase.** Opus 4.6 for phases 0/1/2/5; Sonnet 4.6 for phases 3/4/6; Haiku 4.5 for phase 7's commit message.
119
+
120
+ ## Troubleshooting
121
+
122
+ **Startup fails with "dangerous environment variables present".** A previous shell session exported `ANTHROPIC_API_KEY` (or another billing-routing variable). `unset` it and try again — the tool is intentionally strict so a stray export never costs you money.
123
+
124
+ **Rate limit reached.** Run `code-generator status` to see how many minutes remain on the current pause. The next `code-generator generate --continue` will wait out the rest of the window and resume the same session automatically.
125
+
126
+ **`gh issue create` fails.** Confirm `gh auth status` reports an authenticated SSH session for `github.com`, and that the current directory is inside a repo with a default remote configured.
127
+
128
+ **Tests don't pass after Phase 6.** The orchestrator skips Phase 7 (commit) when the test runner reports persistent failures. Fix the failing tests manually, then run `code-generator generate --continue` to re-enter from where it stopped.
129
+
130
+ ## Project layout
131
+
132
+ ```
133
+ src/code_generator/
134
+ ├── cli.py # Typer entry point: init, generate, review, status
135
+ ├── env.py # DANGEROUS_VARS, build_agent_env, assert_safe_environment
136
+ ├── state.py # State dataclasses + atomic load/save
137
+ ├── prompts/ # Packaged prompt-phase-*.md files + load_prompt
138
+ ├── templates/ # Project templates for `init`
139
+ ├── logging_setup.py # Per-phase log files under .code-generator/logs/
140
+ ├── gh.py # Subprocess wrapper for issues, milestones, labels
141
+ ├── agents.py # Tech-stack detector + agent selection matrix
142
+ ├── runner/
143
+ │ ├── sdk_runner.py # claude-agent-sdk wrapper, RateLimitEvent handling
144
+ │ ├── subprocess_runner.py # CLI fallback, stream-json parser
145
+ │ ├── rate_limit.py # Wait-and-resume main loop
146
+ │ └── retry.py # Backoff + circuit breaker
147
+ ├── orchestrator/
148
+ │ ├── phase0_complexity.py # single vs multi-cycle decision
149
+ │ ├── phase1_plan.py # milestone + issues
150
+ │ ├── phase2_review.py # per-issue review
151
+ │ ├── phase3_4_implement.py # TDD loop, fresh session per issue
152
+ │ ├── phase5_closure.py # closure + fix-issue feedback loop
153
+ │ ├── phase6_test.py # test runner, max 3 retries
154
+ │ ├── phase7_commit.py # Haiku commit message + push with rebase retry
155
+ │ └── cycle_loop.py # multi-cycle driver
156
+ └── commands/ # init, status, generate, review (Typer commands)
157
+ ```
158
+
159
+ ## Development
160
+
161
+ ```bash
162
+ git clone git@github.com:SilvioBaratto/code-generator.git
163
+ cd code-generator
164
+ python -m venv .venv && source .venv/bin/activate
165
+ pip install -e ".[dev]"
166
+ pytest -q
167
+ ruff check src tests
168
+ ```
169
+
170
+ ## Reference
171
+
172
+ The full specification lives in [`requirements.md`](requirements.md). Each prompt file (`prompt-phase-*.md`, `prompt-review.md`) is loaded verbatim by the orchestrator with `{NAME}` placeholders substituted at runtime — edit the prompts there, not inline in Python.
173
+
174
+ ## License
175
+
176
+ MIT.