multi-agents-cli 1.1.9 → 1.1.11
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.
- package/README.md +18 -2
- package/core/templates/.agents/backend/API.md +270 -0
- package/core/templates/.agents/backend/AUTH.md +257 -0
- package/core/templates/.agents/backend/DB.md +268 -0
- package/core/templates/.agents/backend/EVENTS.md +264 -0
- package/core/templates/.agents/backend/INIT.md +250 -0
- package/core/templates/.agents/backend/JOBS.md +267 -0
- package/core/templates/.agents/backend/LOGIC.md +302 -0
- package/core/templates/.agents/backend/TESTING.md +277 -0
- package/core/templates/.agents/client/ACCESSIBILITY.md +277 -0
- package/core/templates/.agents/client/FORMS.md +245 -0
- package/core/templates/.agents/client/LOGIC.md +288 -0
- package/core/templates/.agents/client/ROUTING.md +246 -0
- package/core/templates/.agents/client/TESTING.md +252 -0
- package/core/templates/.agents/client/UI.md +237 -0
- package/core/templates/.agents/shared/CLOUD.md +229 -0
- package/core/templates/.agents/shared/CLOUD_TEARDOWN.md +158 -0
- package/core/templates/.agents/shared/SECURITY.md +297 -0
- package/core/templates/.frameworks/backend/django.md +55 -0
- package/core/templates/.frameworks/backend/express.md +74 -0
- package/core/templates/.frameworks/backend/fastapi.md +107 -0
- package/core/templates/.frameworks/backend/fastify.md +74 -0
- package/core/templates/.frameworks/backend/laravel.md +79 -0
- package/core/templates/.frameworks/backend/nestjs.md +75 -0
- package/core/templates/.frameworks/backend/rails.md +84 -0
- package/core/templates/.frameworks/client/angular.md +80 -0
- package/core/templates/.frameworks/client/nextjs.md +47 -0
- package/core/templates/.frameworks/client/nuxt.md +45 -0
- package/core/templates/.frameworks/client/remix.md +44 -0
- package/core/templates/.frameworks/client/sveltekit.md +44 -0
- package/core/templates/.frameworks/client/vite-react.md +45 -0
- package/core/templates/CLAUDE.md +562 -0
- package/core/templates/CONTRACTS.md +16 -0
- package/core/templates/backend/CLAUDE.md +207 -0
- package/core/templates/client/CLAUDE.md +213 -0
- package/core/workflow/agent.js +285 -6
- package/core/workflow/complete.js +155 -36
- package/core/workflow/reset.js +28 -21
- package/core/workflow/run.js +3 -0
- package/init.js +2 -2
- package/lib/questions-flow.js +13 -2
- package/lib/steps.js +13 -1
- package/lib/ui.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
# {{PROJECT_NAME}} - Global Agent Instructions
|
|
2
|
+
# @config PROJECT_NAME: ← [required] name of this project
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Project Identity
|
|
7
|
+
|
|
8
|
+
<!-- @annotation: 2-3 sentences. What the app does, core stack, why it's a monorepo. -->
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Repo Structure
|
|
13
|
+
|
|
14
|
+
<!-- @annotation: Update tree to match your layout. Default assumes client + backend. -->
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
{{PROJECT_ROOT}}/
|
|
18
|
+
├── .git
|
|
19
|
+
├── CLAUDE.md ← this file (global, always auto-loaded)
|
|
20
|
+
├── CONTRACTS.md ← shared types and enums (single source of truth)
|
|
21
|
+
│
|
|
22
|
+
├── shared/
|
|
23
|
+
│ ├── types/
|
|
24
|
+
│ ├── enums/
|
|
25
|
+
│ └── agents/
|
|
26
|
+
│ └── SECURITY.md # @agent - cross-cutting, invoke from any worktree
|
|
27
|
+
│
|
|
28
|
+
├── backend/ # @project - remove or rename if not applicable
|
|
29
|
+
│ ├── CLAUDE.md ← auto-loaded when in backend/ worktree
|
|
30
|
+
│ └── agents/
|
|
31
|
+
│ ├── INIT.md # @agent
|
|
32
|
+
│ ├── API.md # @agent
|
|
33
|
+
│ ├── LOGIC.md # @agent
|
|
34
|
+
│ ├── AUTH.md # @agent
|
|
35
|
+
│ ├── DB.md # @agent
|
|
36
|
+
│ ├── EVENTS.md # @agent
|
|
37
|
+
│ ├── JOBS.md # @agent
|
|
38
|
+
│ └── TESTING.md # @agent
|
|
39
|
+
│
|
|
40
|
+
├── client/ # @project - remove or rename if not applicable
|
|
41
|
+
│ ├── CLAUDE.md ← auto-loaded when in client/ worktree
|
|
42
|
+
│ └── agents/
|
|
43
|
+
│ ├── UI.md # @agent
|
|
44
|
+
│ ├── LOGIC.md # @agent
|
|
45
|
+
│ ├── FORMS.md # @agent
|
|
46
|
+
│ ├── ROUTING.md # @agent
|
|
47
|
+
│ ├── TESTING.md # @agent
|
|
48
|
+
│ └── ACCESSIBILITY.md # @agent
|
|
49
|
+
│
|
|
50
|
+
└── worktrees/ ← sibling worktree checkouts - never commit this folder
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Worktree & Agent Model
|
|
56
|
+
|
|
57
|
+
Each agent runs in its own Git Worktree on a dedicated branch.
|
|
58
|
+
Agents never share a working directory.
|
|
59
|
+
|
|
60
|
+
**Branch naming:**
|
|
61
|
+
```
|
|
62
|
+
agent/<project>/<scope>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Creating a worktree:**
|
|
66
|
+
Run this from the repo root before starting any agent task:
|
|
67
|
+
```
|
|
68
|
+
git worktree add worktrees/<project>-<scope> -b agent/<project>/<scope>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Examples:
|
|
72
|
+
```
|
|
73
|
+
git worktree add worktrees/client-ui -b agent/client/ui
|
|
74
|
+
git worktree add worktrees/backend-api -b agent/backend/api
|
|
75
|
+
git worktree add worktrees/backend-auth -b agent/backend/auth
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then open Claude Code inside the created worktree folder.
|
|
79
|
+
The `worktrees/` folder is local only - listed in `.gitignore`, never committed.
|
|
80
|
+
|
|
81
|
+
**Context loads in this order:**
|
|
82
|
+
1. Root `CLAUDE.md` - always auto-loaded
|
|
83
|
+
2. `<project>/CLAUDE.md` - auto-loaded per worktree
|
|
84
|
+
3. `agents/<NAME>.md` - manually referenced per prompt
|
|
85
|
+
|
|
86
|
+
> Prompts stay thin. Agent files carry all behavioral detail.
|
|
87
|
+
> Example: `Use agents/UI.md. Task: build the activity table component.`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## CONTRACTS.md Protocol
|
|
92
|
+
|
|
93
|
+
Single source of truth for all types and enums shared across projects.
|
|
94
|
+
Never duplicated inside any project folder.
|
|
95
|
+
|
|
96
|
+
- Any agent may **read** `CONTRACTS.md` and `shared/` freely
|
|
97
|
+
- No agent may **write** to either unilaterally
|
|
98
|
+
- To propose a change, the agent must stop and surface:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
## CONTRACTS CHANGE PROPOSAL
|
|
102
|
+
Agent : <agent name>
|
|
103
|
+
File : CONTRACTS.md or shared/<path>
|
|
104
|
+
Change : <what is being added, modified, or removed>
|
|
105
|
+
Reason : <why this change is needed>
|
|
106
|
+
Impact : <which other agents or projects are affected>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Awaits explicit human approval before proceeding.
|
|
110
|
+
|
|
111
|
+
<!-- @annotation: Default ratification is human-only. Update if your workflow differs. -->
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Coordination Rules
|
|
116
|
+
|
|
117
|
+
1. **Domain isolation** - each agent writes only within its assigned project folder.
|
|
118
|
+
2. **Shared is read-only** - no writes to `shared/` without a ratified proposal.
|
|
119
|
+
3. **No cross-domain assumptions** - use `CONTRACTS.md` as the handshake between agents.
|
|
120
|
+
4. **One branch per agent** - branch = agent + task scope. Never reuse.
|
|
121
|
+
5. **worktrees/ is not committed** - add to `.gitignore`.
|
|
122
|
+
|
|
123
|
+
<!-- @annotation: Add project-specific coordination rules here if needed. -->
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Safety Rules
|
|
128
|
+
|
|
129
|
+
- **Never delete or overwrite** `CONTRACTS.md`, `shared/`, or another agent's files
|
|
130
|
+
- **Never commit directly** to `main` or any protected branch
|
|
131
|
+
- **Never add `Co-Authored-By` to commit messages** — commits are attributed to the project owner only
|
|
132
|
+
- **Never skip the proposal step** when a contract change is required
|
|
133
|
+
- **Stop and flag** any task that requires touching another agent's domain
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Session Start
|
|
138
|
+
|
|
139
|
+
This section fires at the start of every new Claude Code session.
|
|
140
|
+
Regardless of what the user types first - even a single word or greeting -
|
|
141
|
+
the agent must:
|
|
142
|
+
|
|
143
|
+
1. Read `BUILD_STATE.md` at the repo root - understand what has been built
|
|
144
|
+
2. Check if `TASK.md` exists in the current directory
|
|
145
|
+
3. If yes - read it and verify dependencies are met against BUILD_STATE.md
|
|
146
|
+
4. If dependencies not met - surface what is missing and propose options
|
|
147
|
+
5. If dependencies met - begin executing the task defined in TASK.md
|
|
148
|
+
6. If no TASK.md - inform the user to run `npm run agent`
|
|
149
|
+
7. Re-read `TASK.md` at every turn before acting - it is the single source of truth for the current task
|
|
150
|
+
|
|
151
|
+
Do not wait for explicit instructions.
|
|
152
|
+
The presence of `TASK.md` in the worktree is the instruction.
|
|
153
|
+
|
|
154
|
+
## Build State Protocol
|
|
155
|
+
|
|
156
|
+
Before any task begins, read `BUILD_STATE.md` and verify that all required
|
|
157
|
+
predecessor agents for your scope have `COMPLETED` status.
|
|
158
|
+
|
|
159
|
+
| Agent | Requires COMPLETED |
|
|
160
|
+
|-------|-------------------|
|
|
161
|
+
| `client / UI` | — (entry point, no prerequisites) |
|
|
162
|
+
| `client / LOGIC` | `client / UI` |
|
|
163
|
+
| `client / FORMS` | `client / UI` |
|
|
164
|
+
| `client / ROUTING` | `client / UI` |
|
|
165
|
+
| `client / TESTING` | `client / UI` + `client / LOGIC` |
|
|
166
|
+
| `client / ACCESSIBILITY` | `client / UI` |
|
|
167
|
+
| `backend / DB` | — (entry point, no prerequisites) |
|
|
168
|
+
| `backend / INIT` | — (entry point, no prerequisites) |
|
|
169
|
+
| `backend / API` | `backend / INIT` |
|
|
170
|
+
| `backend / LOGIC` | `backend / DB` |
|
|
171
|
+
| `backend / AUTH` | `backend / LOGIC` |
|
|
172
|
+
| `backend / EVENTS` | `backend / INIT` + `backend / API` |
|
|
173
|
+
| `backend / JOBS` | `backend / DB` |
|
|
174
|
+
| `backend / TESTING` | `backend / INIT` + `backend / API` + `backend / LOGIC` |
|
|
175
|
+
| `shared / SECURITY` | — (no hard prerequisites) |
|
|
176
|
+
|
|
177
|
+
If a required predecessor is missing or `IN PROGRESS`:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
## PREREQUISITE NOT MET
|
|
181
|
+
Cannot proceed with <agent> task.
|
|
182
|
+
Required: <predecessor agent> — status: <current status>
|
|
183
|
+
Reason: <why this agent depends on the predecessor>
|
|
184
|
+
Options:
|
|
185
|
+
1. Complete the prerequisite task first
|
|
186
|
+
2. Confirm to proceed anyway with acknowledged risk
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Surface this before reading TASK.md or writing any code.
|
|
190
|
+
Proceed only after explicit human confirmation.
|
|
191
|
+
|
|
192
|
+
## Autonomy Rules
|
|
193
|
+
|
|
194
|
+
When executing a task from `TASK.md`, operate in fully autonomous mode:
|
|
195
|
+
|
|
196
|
+
- **New files** — proceed without confirmation
|
|
197
|
+
- **Modifying existing USER SOURCE CODE** — confirm before proceeding
|
|
198
|
+
(components, pages, configs, APIs, schemas, stylesheets)
|
|
199
|
+
- **Deleting files** — always confirm before proceeding
|
|
200
|
+
- **Do not stop** to ask for plan confirmation unless a destructive action is detected
|
|
201
|
+
- **Do not interrupt** the agentic flow with clarifying questions unless the task
|
|
202
|
+
is genuinely ambiguous after reading all available context files
|
|
203
|
+
|
|
204
|
+
**These workflow files are ALWAYS updated without confirmation:**
|
|
205
|
+
- `TASK.md` — mark `[x] COMPLETED` when your task is done
|
|
206
|
+
- `CONTRACTS.md`
|
|
207
|
+
- `.scaffold/.tracking.json`
|
|
208
|
+
|
|
209
|
+
**NEVER update `BUILD_STATE.md` directly.**
|
|
210
|
+
`complete.js` owns all BUILD_STATE.md updates after merge.
|
|
211
|
+
Editing it in the worktree causes merge conflicts on every task.
|
|
212
|
+
Only update `TASK.md` status to `[x] COMPLETED` — that is sufficient.
|
|
213
|
+
|
|
214
|
+
## User Input Handling
|
|
215
|
+
|
|
216
|
+
If the user types a message mid-session (after the task has started):
|
|
217
|
+
|
|
218
|
+
- Re-read `TASK.md` immediately
|
|
219
|
+
- If the input is within the current agent scope - treat it as a task description update:
|
|
220
|
+
1. Update `TASK.md` with the new task under a `[USER OVERRIDE]` marker
|
|
221
|
+
2. Append the override to `TASKS_HISTORY.md` with timestamp, input, and deviation note
|
|
222
|
+
3. Proceed within the defined agent scope
|
|
223
|
+
- If the input is outside the current agent scope - surface a scope mismatch (see Scope Mismatch Protocol)
|
|
224
|
+
- If the input is completely unrelated to the project domain - flag it clearly and stay on task
|
|
225
|
+
|
|
226
|
+
**WARNING displayed to user on scope mismatch or domain deviation:**
|
|
227
|
+
```
|
|
228
|
+
⚠ Adding messages mid-session may cause the agent to deviate from the
|
|
229
|
+
structured build process. Each agent operates within a defined scope.
|
|
230
|
+
If you need to change direction - stop this session and run npm run agent
|
|
231
|
+
to start a new scoped task instead.
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Scope Mismatch Protocol
|
|
237
|
+
|
|
238
|
+
Before acting on any user input or task description, verify it falls within the current agent scope.
|
|
239
|
+
|
|
240
|
+
If a mismatch is detected:
|
|
241
|
+
1. Do NOT proceed with the out-of-scope work
|
|
242
|
+
2. Surface the mismatch clearly:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
⚠ Scope mismatch detected
|
|
246
|
+
|
|
247
|
+
You are in the [AGENT] agent ([SCOPE] scope).
|
|
248
|
+
The requested task belongs to: [CORRECT AGENT] agent
|
|
249
|
+
|
|
250
|
+
Options:
|
|
251
|
+
1. Stop this session and run npm run agent - select [CORRECT AGENT]
|
|
252
|
+
2. Rephrase the task to stay within [AGENT] scope
|
|
253
|
+
3. Continue anyway (not recommended - may break dependency chain)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
3. Wait for user direction before proceeding
|
|
257
|
+
4. Never silently cross scope boundaries
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Worktree Awareness
|
|
262
|
+
|
|
263
|
+
You are operating inside a git worktree — NOT the main repo root.
|
|
264
|
+
Before editing ANY file, verify you are in your own worktree:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
git rev-parse --show-toplevel # this is your root — stay within it
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Never edit files outside your worktree path. If BUILD_STATE.md or
|
|
271
|
+
any file needs updating, edit the copy inside YOUR worktree root,
|
|
272
|
+
not the main repo's copy.
|
|
273
|
+
|
|
274
|
+
## Implicit Task Clarity Rule
|
|
275
|
+
|
|
276
|
+
This rule applies to ALL agents and overrides individual Pre-flight Check 1 strictness.
|
|
277
|
+
|
|
278
|
+
Before flagging a task as ambiguous, the agent must first attempt to derive intent from:
|
|
279
|
+
|
|
280
|
+
1. **Agent domain** - what this agent is responsible for (UI = components/layout, LOGIC = state/API, etc.)
|
|
281
|
+
2. **@config values** - the confirmed stack defines what to build and how
|
|
282
|
+
3. **BUILD_STATE.md** - current project state defines what exists and what's next
|
|
283
|
+
4. **Scope** - the worktree scope (.claude-scope) defines the boundary
|
|
284
|
+
|
|
285
|
+
If all four sources together make the intent clear - proceed autonomously.
|
|
286
|
+
Only flag for clarification if the task remains genuinely ambiguous AFTER reading all four.
|
|
287
|
+
|
|
288
|
+
**Examples of implicitly clear tasks:**
|
|
289
|
+
- UI agent + empty client/ + full @config + "build the ui" → scaffold the configured stack
|
|
290
|
+
- LOGIC agent + scaffold done + STATE: Zustand + "set up state" → implement Zustand stores
|
|
291
|
+
- TESTING agent + framework set + "set up tests" → configure test runner for the framework
|
|
292
|
+
- ROUTING agent + scaffold done + "set up routing" → configure App Router / routing conventions
|
|
293
|
+
- FORMS agent + LOGIC done + "build forms" → implement form architecture with configured libraries
|
|
294
|
+
|
|
295
|
+
**Examples that still require clarification:**
|
|
296
|
+
- "build the ui" with no @config set → framework unknown, cannot proceed
|
|
297
|
+
- "add a component" with no description → which component, what purpose
|
|
298
|
+
- Any task touching another agent's domain → flag and redirect
|
|
299
|
+
## Output Verification Rule
|
|
300
|
+
|
|
301
|
+
Every agent must verify its output is functional before marking the task complete.
|
|
302
|
+
A task is not done until the output has been verified — not just written.
|
|
303
|
+
|
|
304
|
+
Verification is scope-specific:
|
|
305
|
+
|
|
306
|
+
| Scope | Agent | Verification |
|
|
307
|
+
|-------|-------|-------------|
|
|
308
|
+
| client | UI | `npm install && npm run dev` starts without errors from `client/` |
|
|
309
|
+
| client | LOGIC | `tsc --noEmit` passes with no new errors introduced |
|
|
310
|
+
| client | FORMS | `tsc --noEmit` passes with no new errors introduced |
|
|
311
|
+
| client | ROUTING | `npm run dev` starts and all defined routes resolve |
|
|
312
|
+
| client | TESTING | Test suite runs and all new tests pass |
|
|
313
|
+
| client | ACCESSIBILITY | a11y audit passes on all modified components |
|
|
314
|
+
| backend | INIT | Server starts without errors from `backend/` |
|
|
315
|
+
| backend | API | All defined endpoints respond with expected status codes |
|
|
316
|
+
| backend | AUTH | Auth flow completes without errors |
|
|
317
|
+
| backend | DB | Migrations run cleanly, schema matches entities |
|
|
318
|
+
| backend | LOGIC | Unit tests pass for all new business logic |
|
|
319
|
+
| backend | EVENTS | Event handlers register and fire without errors |
|
|
320
|
+
| backend | JOBS | Jobs register and execute without errors |
|
|
321
|
+
| shared | SECURITY | All security checks pass with no critical findings |
|
|
322
|
+
|
|
323
|
+
If verification fails:
|
|
324
|
+
1. Fix the issue before marking complete — do not defer to another agent
|
|
325
|
+
2. If the failure is caused by another agent's code, surface it explicitly before proceeding
|
|
326
|
+
3. Never mark `[x] COMPLETED` in TASK.md until verification passes
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Tracking Protocol
|
|
331
|
+
|
|
332
|
+
Every agent reads `.scaffold/.tracking.json` at session start.
|
|
333
|
+
This file records the current state of every agent slot.
|
|
334
|
+
|
|
335
|
+
**Slot schema:**
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"branch": "agent/{scope}/{agent}/{timestamp} | null",
|
|
339
|
+
"timestamp": "numeric timestamp | null",
|
|
340
|
+
"launchedAt": "ISO date string | null",
|
|
341
|
+
"status": "ACTIVE | MISSING | null",
|
|
342
|
+
"missingCount": "number (informational — not a blocking signal)",
|
|
343
|
+
"worktreePath": "absolute path | null"
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Status meanings:**
|
|
348
|
+
- `null` — never launched
|
|
349
|
+
- `ACTIVE` — currently running
|
|
350
|
+
- `MISSING` — worktree was deleted without completing
|
|
351
|
+
|
|
352
|
+
**Agent rules:**
|
|
353
|
+
- If your slot shows `MISSING` — a decision gate fired before you started. Follow the Recovery Notes in TASK.md if present.
|
|
354
|
+
- If your slot shows `ACTIVE` — you are the active instance. Do not create parallel work.
|
|
355
|
+
- Never write directly to `.tracking.json` — managed by workflow scripts only.
|
|
356
|
+
|
|
357
|
+
## Paths Protocol
|
|
358
|
+
|
|
359
|
+
`.scaffold/.paths.json` maps expected and actual framework paths for the project.
|
|
360
|
+
Written at init time with `status: pending`. Updated by agents after scaffolding.
|
|
361
|
+
|
|
362
|
+
**Schema:**
|
|
363
|
+
```json
|
|
364
|
+
{
|
|
365
|
+
"client": {
|
|
366
|
+
"typesDir": {
|
|
367
|
+
"expected": "client/src/types",
|
|
368
|
+
"current": null,
|
|
369
|
+
"status": "pending"
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"backend": {
|
|
373
|
+
"schemasDir": {
|
|
374
|
+
"expected": "backend/app/schemas",
|
|
375
|
+
"current": null,
|
|
376
|
+
"status": "pending"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Status values:**
|
|
383
|
+
- `pending` — path not yet created (agent hasn't scaffolded yet)
|
|
384
|
+
- `verified` — agent confirmed path exists on disk
|
|
385
|
+
- `diverged` — actual path differs from expected (update `current` with real path)
|
|
386
|
+
|
|
387
|
+
**Agent rules:**
|
|
388
|
+
- After scaffolding your framework, read `.scaffold/.paths.json`
|
|
389
|
+
- Verify each path in your scope exists on disk
|
|
390
|
+
- Update `current` with the actual path and set `status: verified` or `diverged`
|
|
391
|
+
- If `diverged` — use the `current` path going forward, not `expected`
|
|
392
|
+
- Other agents reading this file should use `current` if set, fall back to `expected`
|
|
393
|
+
|
|
394
|
+
## Remote Setup Protocol
|
|
395
|
+
|
|
396
|
+
**Context:** `npm run init` commits the project locally but does NOT push
|
|
397
|
+
to a remote. The template origin is removed during init and moved to
|
|
398
|
+
`upstream`. The project has no remote until one is configured.
|
|
399
|
+
|
|
400
|
+
If `.scaffold/.remote-setup-needed` exists at session start, this MUST
|
|
401
|
+
be resolved before any task work begins. The deployment chain
|
|
402
|
+
(`npm run complete → git push origin main`) will fail without it.
|
|
403
|
+
|
|
404
|
+
**Step 1 — Check if already configured:**
|
|
405
|
+
```bash
|
|
406
|
+
git remote get-url origin
|
|
407
|
+
```
|
|
408
|
+
→ Origin exists: delete flag, proceed with task ✓
|
|
409
|
+
→ No origin: continue to Step 2
|
|
410
|
+
|
|
411
|
+
**Step 2 — Silent background authentication detection (OS-aware):**
|
|
412
|
+
|
|
413
|
+
Run all checks silently. Stop at the first that succeeds.
|
|
414
|
+
|
|
415
|
+
Mac:
|
|
416
|
+
```bash
|
|
417
|
+
ssh -T git@github.com 2>&1 # exit 1 = authenticated
|
|
418
|
+
gh auth status 2>/dev/null # gh authenticated
|
|
419
|
+
git ls-remote https://github.com # HTTPS creds in Keychain
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Windows:
|
|
423
|
+
```bash
|
|
424
|
+
ssh -T git@github.com # SSH
|
|
425
|
+
gh auth status # gh
|
|
426
|
+
git ls-remote https://github.com # Windows Credential Manager
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
Linux:
|
|
430
|
+
```bash
|
|
431
|
+
ssh -T git@github.com # SSH
|
|
432
|
+
gh auth status # gh
|
|
433
|
+
git ls-remote https://github.com # ~/.git-credentials
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Step 3 — Act on first successful method:**
|
|
437
|
+
|
|
438
|
+
SSH authenticated:
|
|
439
|
+
```bash
|
|
440
|
+
# Ask username, derive SSH remote
|
|
441
|
+
git remote add origin git@github.com:{username}/{projectName}.git
|
|
442
|
+
git ls-remote --heads origin # check for existing branches
|
|
443
|
+
# if branches exist → surface warning, offer Reuse (clear + reinit) or New repo
|
|
444
|
+
git push -u origin main ✓
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
gh authenticated:
|
|
448
|
+
```bash
|
|
449
|
+
gh repo view {username}/{projectName} 2>/dev/null
|
|
450
|
+
# if exists + has branches → surface warning, offer Reuse (clear + reinit) or New repo
|
|
451
|
+
# if exists + empty → use it
|
|
452
|
+
# if not exists → gh repo create {projectName} --public --source=. --remote=origin --push ✓
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
HTTPS credentials found:
|
|
456
|
+
```bash
|
|
457
|
+
# Ask username, derive HTTPS remote
|
|
458
|
+
git remote add origin https://github.com/{username}/{projectName}
|
|
459
|
+
git ls-remote --heads origin # check for existing branches
|
|
460
|
+
# if branches exist → surface warning, offer Reuse (clear + reinit) or New repo
|
|
461
|
+
git push -u origin main ✓
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**Step 4 — ALL silent methods failed → browser (last resort only):**
|
|
465
|
+
|
|
466
|
+
Ask for GitHub username only:
|
|
467
|
+
```
|
|
468
|
+
"What's your GitHub username?"
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Derive URL: `https://github.com/new?name={projectName}`
|
|
472
|
+
|
|
473
|
+
Open browser (OS-aware — check .app exists before using):
|
|
474
|
+
```bash
|
|
475
|
+
# Mac:
|
|
476
|
+
open "https://github.com/new?name={projectName}"
|
|
477
|
+
# Windows:
|
|
478
|
+
start "" "https://github.com/new?name={projectName}"
|
|
479
|
+
# Linux:
|
|
480
|
+
xdg-open "https://github.com/new?name={projectName}"
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Then output this waiting prompt EXACTLY — formatted prominently so it cannot be missed:
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
## ⚠️ Action Required — GitHub Repo Setup
|
|
487
|
+
|
|
488
|
+
The repo creation page is now open in your browser.
|
|
489
|
+
|
|
490
|
+
**Do this now:**
|
|
491
|
+
1. Repo name: **`{projectName}`** (already pre-filled)
|
|
492
|
+
2. Leave all other settings as default
|
|
493
|
+
3. Click **"Create repository"**
|
|
494
|
+
4. Come back here and **type `done`** to continue
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
Wait for the user to type `done` before proceeding.
|
|
499
|
+
|
|
500
|
+
Validate on return:
|
|
501
|
+
```bash
|
|
502
|
+
git ls-remote https://github.com/{username}/{projectName}
|
|
503
|
+
```
|
|
504
|
+
→ 200 success, no branches: set origin, push ✓
|
|
505
|
+
→ 200 success, has branches:
|
|
506
|
+
Run full evaluation before surfacing anything to user:
|
|
507
|
+
|
|
508
|
+
```bash
|
|
509
|
+
# 1. Check for orphaned agent branches (unmerged work)
|
|
510
|
+
git ls-remote --heads origin 'refs/heads/agent/*'
|
|
511
|
+
|
|
512
|
+
# 2. Check last commit message on remote main
|
|
513
|
+
git log origin/main -1 --format="%s"
|
|
514
|
+
|
|
515
|
+
# 3. Check last commit timestamp
|
|
516
|
+
git log origin/main -1 --format="%ct"
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Decision logic:
|
|
520
|
+
|
|
521
|
+
Orphaned agent/* branches exist:
|
|
522
|
+
→ Surface to user — unfinished work may be recoverable:
|
|
523
|
+
"⚠ Unfinished work detected from a previous session.
|
|
524
|
+
Orphaned branches: {list}
|
|
525
|
+
1. Recover — restore previous worktree and continue
|
|
526
|
+
2. Clear — delete all remote history, start fresh"
|
|
527
|
+
|
|
528
|
+
No orphaned branches + last commit > 24 hours ago:
|
|
529
|
+
→ Auto-clear silently, proceed
|
|
530
|
+
(old session, clearly abandoned, no decision needed)
|
|
531
|
+
|
|
532
|
+
No orphaned branches + last commit < 24 hours ago + last commit is merge/completed:
|
|
533
|
+
→ Auto-clear silently, proceed
|
|
534
|
+
(previous session completed cleanly)
|
|
535
|
+
|
|
536
|
+
No orphaned branches + last commit < 24 hours ago + last commit is incomplete (build: X started):
|
|
537
|
+
→ Surface to user:
|
|
538
|
+
"⚠ A recent incomplete session was detected ({timestamp}).
|
|
539
|
+
1. Clear — delete remote history, start fresh
|
|
540
|
+
2. Keep — use a different repo name"
|
|
541
|
+
|
|
542
|
+
Auto-clear procedure:
|
|
543
|
+
gh available:
|
|
544
|
+
gh repo delete {username}/{projectName} --yes
|
|
545
|
+
gh repo create {projectName} --public --source=. --remote=origin --push ✓
|
|
546
|
+
gh not available:
|
|
547
|
+
git push origin main --force
|
|
548
|
+
git ls-remote --heads origin → delete each remote branch except main ✓
|
|
549
|
+
→ 404 not found: retry prompt
|
|
550
|
+
→ 403 auth error: "Verify username or repo visibility" → re-ask
|
|
551
|
+
→ timeout: "Check your connection" → retry option
|
|
552
|
+
|
|
553
|
+
**Step 5 — Cleanup on success:**
|
|
554
|
+
```bash
|
|
555
|
+
git push -u origin main
|
|
556
|
+
rm .scaffold/.remote-setup-needed
|
|
557
|
+
```
|
|
558
|
+
Log completion in TASK.md checklist.
|
|
559
|
+
Confirm: "Remote configured — proceeding with task."
|
|
560
|
+
|
|
561
|
+
**Never begin task implementation until this flag is cleared.
|
|
562
|
+
Never delete the flag on failure.**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# CONTRACTS.md
|
|
2
|
+
# Single source of truth for all types and enums shared across client and backend.
|
|
3
|
+
# Never duplicated inside any project folder.
|
|
4
|
+
# Changes require an explicit proposal and human approval — see root CLAUDE.md.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Types
|
|
9
|
+
|
|
10
|
+
<!-- Add shared TypeScript interfaces here -->
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Enums
|
|
15
|
+
|
|
16
|
+
<!-- Add shared enums here -->
|