You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: restructure as multi-stack monorepo with shared CLI
Move Laravel stack files into stacks/laravel/, rename CLI to
@reyemtech/stack-upgrade with multi-stack detection, multi-upgrade
queue, and parallel container/pod launching. Add npm-publish job
and per-stack matrix builds to CI. Rewrite README and CLAUDE.md
for multi-stack architecture.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+77-65Lines changed: 77 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,28 +1,48 @@
1
-
# CLAUDE.md — Laravel Upgrade Agent (Dev)
1
+
# CLAUDE.md — Stack Upgrade Agent (Dev)
2
2
3
-
Instructions for developing the laravel-upgrade-agent itself (not for the agent running inside Docker).
3
+
Instructions for developing the stack-upgrade project itself (not for the agent running inside Docker).
4
4
5
5
## What This Project Is
6
6
7
-
A disposable Docker image that runs Claude Code autonomously to upgrade any Laravel app. It clones a repo, creates an `upgrade/laravel-{version}` branch, works through 7 phases, commits per phase, and pushes. Optionally creates a PR with a generated changelog.
7
+
A multi-stack monorepo of disposable Docker images that run Claude Code autonomously to upgrade applications. Each stack (Laravel, React, Rails, etc.) lives in `stacks/{name}/` with its own Dockerfile, entrypoint, templates, and scripts. A shared CLI (`@reyemtech/stack-upgrade`) handles repo discovery, stack detection, and launching upgrades via Docker or Kubernetes.
8
+
9
+
Currently supports **Laravel**. Future stacks are added by creating a new `stacks/{name}/` directory and registering it in `cli/src/stacks.js`.
8
10
9
11
## Architecture
10
12
11
13
```
12
-
entrypoint.sh # Clone repo, setup branch, install deps, recon, drop templates, launch ralph loop
13
-
scripts/ralph-loop.sh # Restart loop — relaunches Claude Code if it exits before checklist complete
|`checklist.yaml`| Executable work items with acceptance criteria and status | Template: `stacks/laravel/templates/checklist.yaml` -> dropped into `.upgrade/`|
### Execution Loop (what the agent does per phase)
66
86
@@ -80,7 +100,7 @@ The agent's durable memory survives context compaction and session restarts:
80
100
-**Checkpoint constantly** — one commit per phase, reversible steps
81
101
-**Loop breaker** — after 3 failed attempts on the same error, log failure, mark phase `failed`, move on (prevents infinite loops)
82
102
-**Ralph loop** — restart harness that relaunches Claude Code if it exits before checklist is complete (handles context exhaustion gracefully)
83
-
-**Recon before action** — `scripts/recon.sh` maps the repo (package usage, component counts, test shape) before the agent starts
103
+
-**Recon before action** — `stacks/laravel/scripts/recon.sh` maps the repo (package usage, component counts, test shape) before the agent starts
84
104
-**Self-evolve** — after every run, review `run-log.md` for patterns that should become template/constraint changes
85
105
86
106
### Steering Messages (for manual intervention during a run)
@@ -94,18 +114,18 @@ If you need to steer the agent mid-run (via Docker exec or modifying files):
94
114
## Key Concepts
95
115
96
116
-**Templates** use `${TARGET_LARAVEL}` and `${UPGRADE_DATE}` — substituted by `envsubst` in entrypoint.sh
97
-
-**Ralph loop** (`scripts/ralph-loop.sh`) restarts Claude Code up to `MAX_RESTARTS` times if checklist has incomplete tasks
98
-
-**Branch handling** (`entrypoint.sh`): checks if remote branch exists first — if yes, checks out and rebases; if no, creates fresh. Supports `BRANCH_SUFFIX` for repeat runs.
117
+
-**Ralph loop** (`stacks/laravel/scripts/ralph-loop.sh`) restarts Claude Code up to `MAX_RESTARTS` times if checklist has incomplete tasks
118
+
-**Branch handling** (`stacks/laravel/entrypoint.sh`): checks if remote branch exists first — if yes, checks out and rebases; if no, creates fresh. Supports `BRANCH_SUFFIX` for repeat runs.
99
119
-**One commit per phase** — no intermediate commits within a phase
100
120
-**Push + PR** — push happens at end of ralph-loop.sh (controlled by `GIT_PUSH`). If `GH_TOKEN` is set, a PR is auto-created using `.upgrade/changelog.md` as the body.
101
121
-**Structured exit** — exit 0 = all complete, exit 1 = incomplete. `/output/result.json` has outcome summary.
102
122
-**Status monitoring** — `/output/status.json` is updated throughout the run for external monitoring.
103
123
-**Dependency snapshots** — before/after JSON snapshots of composer and npm packages saved to `/output/` for diff-based review.
104
-
-**Recon** — `scripts/recon.sh` produces `.upgrade/recon-report.md` with package usage analysis, component counts, test suite shape.
124
+
-**Recon** — `stacks/laravel/scripts/recon.sh` produces `.upgrade/recon-report.md` with package usage analysis, component counts, test suite shape.
105
125
-**Upgrade guide** — official Laravel upgrade docs fetched and saved to `.upgrade/laravel-upgrade-guide.html`.
106
126
-**No CLAUDE.md overwrite** — upgrade instructions go to `.upgrade/CLAUDE.md`; the target repo's own `CLAUDE.md` is preserved.
The CLI (`cli/`) is published as `@reyemtech/stack-upgrade` (binary: `stack-upgrade`). It:
140
+
141
+
1. Auto-detects Claude credentials (OAuth or API key) from multiple sources
142
+
2. Discovers repos via GitHub CLI, detects stack type from `composer.json`
143
+
3. Supports queuing multiple upgrades to run in parallel
144
+
4. Launches via Docker (local) or Kubernetes (remote cluster)
145
+
5. Persists preferences to `~/.stack-upgrade/config.json`
146
+
147
+
### Stack Registry (`cli/src/stacks.js`)
148
+
149
+
Each stack is registered with: name, Docker image, detection function, version prompt label, branch prefix, and env key. Adding a new stack means adding an entry here.
150
+
117
151
## Environment Variables
118
152
119
153
| Variable | Required | Default | Description |
@@ -155,8 +189,8 @@ After a run, `/output/` contains:
-**`.upgrade/` folder** — all upgrade artifacts now live in `.upgrade/` instead of the workspace root; target repo's `CLAUDE.md` is preserved
197
-
-**Recon phase** — `scripts/recon.sh` maps package usage, component counts, and test shape before the agent starts
198
-
-**Changelog** — agent maintains `.upgrade/changelog.md` per phase; used as PR body
199
-
-**Upgrade guide fetch** — official Laravel upgrade docs fetched to `.upgrade/laravel-upgrade-guide.html`
200
-
-**Dependency snapshots** — before/after JSON snapshots for diff-based review
201
-
-**Structured exit** — exit 0/1 with `/output/result.json` summary
202
-
-**Status monitoring** — `/output/status.json` updated throughout for external monitoring
203
-
-**Auto PR** — `gh pr create` when `GH_TOKEN` is set
204
-
-**Branch suffix** — `BRANCH_SUFFIX` env var for repeat runs without collision
205
-
-**Branch reuse** — entrypoint.sh checks for existing remote branch and rebases instead of blindly creating
206
-
-**Upgrade philosophy** — "never modify business logic" replaced with "never change application behaviour" so major package upgrades proceed with required code changes
207
-
-**Unused package removal** — agent removes packages not imported anywhere instead of upgrading them
208
-
-**Flux/flux-pro awareness** — Phase 3 checks for livewire/flux and livewire/flux-pro
213
+
## Adding a New Stack
214
+
215
+
1. Create `stacks/{name}/` with `Dockerfile`, `entrypoint.sh`, `templates/`, and `scripts/`
216
+
2. Add the stack to `cli/src/stacks.js` with detection logic, image name, and env key
217
+
3. Add the stack to the `matrix.stack` array in `.github/workflows/release.yml`
218
+
4. Image will be published as `ghcr.io/reyemtech/{name}-upgrade-agent`
209
219
210
220
## Commit Convention
211
221
@@ -224,21 +234,23 @@ This project uses [Conventional Commits](https://www.conventionalcommits.org/) f
224
234
|`refactor`| Code restructuring, no behavior change | No release |
225
235
|`test`| Adding or fixing tests | No release |
226
236
227
-
**Scopes** (optional but encouraged): `entrypoint`, `ralph`, `recon`, `templates`, `dockerfile`, `ci`
0 commit comments