@contextium/cli 1.0.14 → 1.0.16
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/package.json +1 -1
- package/skills/ium/contextium.md +26 -0
- package/skills/ium/help.md +4 -0
- package/skills/ium/new-project.md +89 -41
- package/skills/ium/resume-project.md +35 -41
- package/skills/ium/scan-existing.md +422 -0
package/package.json
CHANGED
package/skills/ium/contextium.md
CHANGED
|
@@ -49,6 +49,32 @@ Workspace
|
|
|
49
49
|
| A role combining multiple skills? | Agent |
|
|
50
50
|
| Ready-to-use context package for a task? | Workflow |
|
|
51
51
|
|
|
52
|
+
## Contextium Is the Source of Truth
|
|
53
|
+
|
|
54
|
+
All AI-relevant information — project state, SOPs, constraints, decisions, research, planning — lives in Contextium. It is always written to Contextium first. Local files are only for things that belong in git: source code, config, READMEs.
|
|
55
|
+
|
|
56
|
+
Never write AI planning or knowledge files locally by default. If a user specifically asks for a local copy of something, write it — but Contextium is always written first and is always authoritative.
|
|
57
|
+
|
|
58
|
+
This gives users something local file-based tools cannot: state survives machine loss, team members share the same context, and multiple projects run in parallel — one workflow loaded per terminal session — with no interference between them.
|
|
59
|
+
|
|
60
|
+
## Multi-Project Rule
|
|
61
|
+
|
|
62
|
+
Each project must have its own dedicated context library. Never mix two projects into one library.
|
|
63
|
+
|
|
64
|
+
The project state file (`project-state.md`) is the single source of truth for a project's current position, locked decisions, and seeds. **Only one `project-state.md` should ever exist per library.** If a second one would need to be created in the same library, stop and ask the user to use a different library or create a new one.
|
|
65
|
+
|
|
66
|
+
## Decision Routing
|
|
67
|
+
|
|
68
|
+
When a significant architectural, technical, or approach decision is made during any session, write it to the `## Decisions Log` in `project-state.md` immediately — no user permission needed. Log it silently and mention it in the phase summary.
|
|
69
|
+
|
|
70
|
+
A decision qualifies if it:
|
|
71
|
+
- Picks a technology or library
|
|
72
|
+
- Sets an API contract or data model
|
|
73
|
+
- Establishes a pattern future phases will depend on
|
|
74
|
+
- Rules out an approach that was considered
|
|
75
|
+
|
|
76
|
+
Decisions in the log are **locked**. Future sessions must not re-debate them. If the user explicitly wants to revisit a decision, they must say so — only then update the entry.
|
|
77
|
+
|
|
52
78
|
## File Routing — Writing Files When Contextium Is Connected
|
|
53
79
|
|
|
54
80
|
When the Contextium MCP is connected or the CLI is active, **any time a new file is about to be created**, intercept it with a routing question before writing:
|
package/skills/ium/help.md
CHANGED
|
@@ -17,6 +17,10 @@ Output the following help reference directly — no tools needed:
|
|
|
17
17
|
╚══════════════════════════════════════════════════════════════╝
|
|
18
18
|
|
|
19
19
|
GETTING STARTED
|
|
20
|
+
/ium:scan-existing Scan an existing codebase and write analysis docs to
|
|
21
|
+
Contextium — stack, architecture, conventions, concerns.
|
|
22
|
+
Run this before /ium:new-project on existing projects.
|
|
23
|
+
|
|
20
24
|
/ium:new-project Set up a new Contextium project from scratch —
|
|
21
25
|
auth, workspace, libraries, agents, skills, workflow
|
|
22
26
|
|
|
@@ -92,6 +92,19 @@ If yes:
|
|
|
92
92
|
If no: continue to project description with a clean slate.
|
|
93
93
|
</step>
|
|
94
94
|
|
|
95
|
+
<step name="codebase_scan_check">
|
|
96
|
+
Silently check whether any library in the selected workspace contains codebase analysis documents from `/ium:scan-existing`. Look for files named `stack.md`, `architecture.md`, `structure.md`, `conventions.md`, `concerns.md` in any library.
|
|
97
|
+
|
|
98
|
+
**CLI:** `contextium library list --workspace <slug> 2>/dev/null` then check file lists per library
|
|
99
|
+
**MCP:** call mcp__contextium__list_context_libraries, then mcp__contextium__list_files for each
|
|
100
|
+
|
|
101
|
+
If found, read `architecture.md` and `stack.md` silently to understand what already exists. Store this as `has_codebase_scan = true` and `codebase_library = <library name>`. This will be used later to pre-populate validated capabilities in the project state.
|
|
102
|
+
|
|
103
|
+
If not found, set `has_codebase_scan = false` and continue.
|
|
104
|
+
|
|
105
|
+
Do not mention this check to the user.
|
|
106
|
+
</step>
|
|
107
|
+
|
|
95
108
|
<step name="project_description">
|
|
96
109
|
Ask the user this question exactly:
|
|
97
110
|
|
|
@@ -202,7 +215,7 @@ If no: set `research_agent_planned = false` and continue.
|
|
|
202
215
|
<step name="planner_question">
|
|
203
216
|
Ask the user:
|
|
204
217
|
|
|
205
|
-
"Would you like a project planner to break your project into phases and track progress? I'll create a planning agent and a
|
|
218
|
+
"Would you like a project planner to break your project into phases and track progress? I'll create a planning agent and a state document you can follow from start to finish."
|
|
206
219
|
|
|
207
220
|
Use AskUserQuestion:
|
|
208
221
|
- "Yes, add a project planner"
|
|
@@ -210,23 +223,59 @@ Use AskUserQuestion:
|
|
|
210
223
|
|
|
211
224
|
If yes:
|
|
212
225
|
1. Add a "**[Project Name] Planner**" agent to the creation plan — its role is to define project phases, estimate scope, and guide execution in order. Tailor its system prompt to the project domain. Store as `planner_planned = true`.
|
|
213
|
-
2. After all resources are created, create a
|
|
226
|
+
2. After all resources are created, create a project state document in the most relevant library. This is the living memory for the project — not just a phase list. Use this exact structure:
|
|
214
227
|
|
|
215
228
|
```markdown
|
|
216
|
-
# [Project Name] — Project
|
|
229
|
+
# [Project Name] — Project State
|
|
217
230
|
|
|
218
|
-
##
|
|
231
|
+
## Current Position
|
|
232
|
+
**Phase:** Phase 1: [Name]
|
|
233
|
+
**Status:** Not Started
|
|
234
|
+
**Last Updated:** [today's date]
|
|
235
|
+
**Next Action:** Begin Phase 1
|
|
236
|
+
|
|
237
|
+
## Already Built
|
|
238
|
+
> Capabilities confirmed by codebase scan — these do not need to be built.
|
|
239
|
+
> _(Remove this section if starting a greenfield project with no existing code)_
|
|
240
|
+
|
|
241
|
+
- ✓ [Existing capability — e.g. "Express API with JWT auth"] — `src/server.ts`
|
|
242
|
+
- ✓ [Existing capability] — `src/`
|
|
243
|
+
|
|
244
|
+
## Phases
|
|
245
|
+
|
|
246
|
+
### Phase 1: [Name]
|
|
219
247
|
**Status:** Not Started
|
|
220
248
|
[Brief description of what this phase covers]
|
|
221
249
|
|
|
222
|
-
|
|
250
|
+
### Phase 2: [Name]
|
|
223
251
|
**Status:** Not Started
|
|
224
252
|
[Brief description]
|
|
225
253
|
|
|
226
254
|
...
|
|
255
|
+
|
|
256
|
+
## Decisions Log
|
|
257
|
+
> Locked decisions — record here when a significant architectural, technical, or approach decision is made. Do not re-debate entries in this log.
|
|
258
|
+
|
|
259
|
+
| Decision | Rationale | Phase |
|
|
260
|
+
|----------|-----------|-------|
|
|
261
|
+
| _(none yet)_ | | |
|
|
262
|
+
|
|
263
|
+
## Seeds
|
|
264
|
+
> Ideas and suggestions to revisit at the right time — not immediate work.
|
|
265
|
+
|
|
266
|
+
| Idea | When to revisit | Context |
|
|
267
|
+
|------|-----------------|---------|
|
|
268
|
+
| _(none yet)_ | | |
|
|
269
|
+
|
|
270
|
+
## Notes
|
|
271
|
+
_(ad-hoc notes that don't fit elsewhere)_
|
|
227
272
|
```
|
|
228
273
|
|
|
229
|
-
Infer sensible phases from the project description.
|
|
274
|
+
Infer sensible phases from the project description. Title the file `project-state.md`.
|
|
275
|
+
|
|
276
|
+
**If `has_codebase_scan = true`:** populate the `## Already Built` section from the `architecture.md` found in the codebase scan library — list the key capabilities that clearly already exist. Only plan phases for what is **not** in the Already Built list. If starting greenfield, remove the Already Built section entirely.
|
|
277
|
+
|
|
278
|
+
**Important:** Only one `project-state.md` should ever exist per context library. This is the single source of truth for this project. Never create a second one or split state across multiple files.
|
|
230
279
|
|
|
231
280
|
If no: set `planner_planned = false` and continue.
|
|
232
281
|
</step>
|
|
@@ -238,25 +287,17 @@ Do NOT create a workflow in this step.
|
|
|
238
287
|
|
|
239
288
|
Show `✓ Created "Name"` for each item as it is created. Show `↗ Reusing "Name"` for each existing resource being included.
|
|
240
289
|
|
|
241
|
-
If `planner_planned = true`, create the project
|
|
290
|
+
If `planner_planned = true`, create the project state file in Contextium after all other resources are created:
|
|
242
291
|
|
|
243
292
|
**CLI:**
|
|
244
293
|
```bash
|
|
245
|
-
cat << 'EOF' | contextium new <library-name> -t "[Project Name] — Project
|
|
246
|
-
<generated
|
|
294
|
+
cat << 'EOF' | contextium new <library-name> -t "[Project Name] — Project State" -p "project-state.md" --stdin -w <workspace>
|
|
295
|
+
<generated state content>
|
|
247
296
|
EOF
|
|
248
297
|
```
|
|
249
|
-
**MCP:** call mcp__contextium__create_file with the
|
|
298
|
+
**MCP:** call mcp__contextium__create_file with the state content.
|
|
250
299
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
mkdir -p .ium-planning && cat << 'EOF' > .ium-planning/project-plan.md
|
|
255
|
-
<same generated phase content>
|
|
256
|
-
EOF
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
Show `✓ Created project plan "project-plan.md"` and `✓ Saved local backup to .ium-planning/project-plan.md` when done.
|
|
300
|
+
Show `✓ Created project state "project-state.md"` when done.
|
|
260
301
|
|
|
261
302
|
Suppress all errors silently — if something fails, skip it quietly and note it in the summary.
|
|
262
303
|
|
|
@@ -323,7 +364,7 @@ Use AskUserQuestion:
|
|
|
323
364
|
- "Yes, start planning now"
|
|
324
365
|
- "No, I'll do it later"
|
|
325
366
|
|
|
326
|
-
If yes: activate the planner agent — instruct it to analyse the project description and produce a detailed phased plan, updating the `project-
|
|
367
|
+
If yes: activate the planner agent — instruct it to analyse the project description and produce a detailed phased plan, updating the `project-state.md` file created earlier with specific tasks, milestones, and sequencing. Let it run and surface the plan to the user.
|
|
327
368
|
|
|
328
369
|
If no: continue to summary.
|
|
329
370
|
</step>
|
|
@@ -364,16 +405,24 @@ If anything failed to create, add a single line at the end:
|
|
|
364
405
|
These rules apply for the duration of the project, after setup is complete.
|
|
365
406
|
|
|
366
407
|
**New suggestions and feature ideas**
|
|
367
|
-
- Whenever a new feature, idea, or suggestion comes up during the project, ask: "Would you like to add this to the project
|
|
368
|
-
- If yes: append it to `project-
|
|
408
|
+
- Whenever a new feature, idea, or suggestion comes up during the project, ask: "Would you like to add this to the project state as a seed to revisit later?"
|
|
409
|
+
- If yes: append it to the `## Seeds` section of `project-state.md` in Contextium with a "When to revisit" trigger (e.g. "When Phase 3 begins", "When load testing reveals bottlenecks") and a brief context note.
|
|
369
410
|
- If no: note it and continue with the current work
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
- If the user
|
|
376
|
-
-
|
|
411
|
+
- Seeds are NOT immediate work — never promote a seed to a phase without the user asking
|
|
412
|
+
|
|
413
|
+
**Decision locking**
|
|
414
|
+
- Whenever a significant architectural, technical, or approach decision is made during a phase, write it to the `## Decisions Log` table in `project-state.md` in Contextium immediately.
|
|
415
|
+
- A decision qualifies if it: picks a technology, sets an API contract, defines a data model, or establishes a pattern that future phases will depend on
|
|
416
|
+
- Decisions in the log are **locked** — do not re-debate them in future sessions. If the user wants to revisit a decision, they must explicitly say so; only then remove or update the entry
|
|
417
|
+
- Never ask the user's permission to log a decision — just do it silently and mention it in the phase summary
|
|
418
|
+
|
|
419
|
+
**Tackling a new feature or phase**
|
|
420
|
+
- When the user is ready to start work on a new feature or area of the project:
|
|
421
|
+
1. Update `## Current Position` in `project-state.md` in Contextium to reflect the new phase — set Phase, Status to "In Progress", and Next Action.
|
|
422
|
+
2. Ask: "Would you like to run a research phase on this first?" — if a research agent exists, use it; otherwise offer to create one
|
|
423
|
+
3. Ask: "Would you like a phased plan for this?" — if a planner agent exists, use it; otherwise offer to create one
|
|
424
|
+
- If the user says no to both, continue directly using existing agents — no extra setup needed
|
|
425
|
+
- Treat each new feature as its own mini-project using existing workspace resources — never create duplicate agents or skills if suitable ones already exist
|
|
377
426
|
|
|
378
427
|
**Suggesting new agents and skills**
|
|
379
428
|
- If the work the user is describing would clearly benefit from an agent or skill that doesn't exist yet, proactively suggest creating one — explain what it would do and why it would help
|
|
@@ -383,28 +432,27 @@ These rules apply for the duration of the project, after setup is complete.
|
|
|
383
432
|
**Session usage check at end of every phase**
|
|
384
433
|
- At the end of every completed phase, check the current session context usage (visible in the Claude Code status bar as a percentage)
|
|
385
434
|
- If usage is **above 50%**, do the following automatically before prompting the user to continue:
|
|
386
|
-
1.
|
|
387
|
-
2.
|
|
388
|
-
3. Tell the user:
|
|
435
|
+
1. Update `project-state.md` in Contextium — mark the phase "Complete" or "In Progress", update `## Current Position` to point to the next phase, and add a `> Session Handoff` block under the current phase containing: what was completed, decisions made this session (list them), what the next phase requires, and open questions.
|
|
436
|
+
2. Tell the user:
|
|
389
437
|
|
|
390
438
|
```
|
|
391
439
|
⚠ Session is above 50% — recommended to start a fresh session before the next phase.
|
|
392
440
|
|
|
393
|
-
|
|
441
|
+
Project state has been saved to your Contextium library.
|
|
394
442
|
Run /ium:resume-project to pick up exactly where you left off.
|
|
395
443
|
```
|
|
396
444
|
|
|
397
|
-
- If usage is **below 50%**,
|
|
445
|
+
- If usage is **below 50%**, confirm the phase is complete, update `## Current Position` to the next phase, and ask if the user is ready to move on
|
|
398
446
|
- Never skip this check at phase end — even if the user seems eager to continue
|
|
399
447
|
|
|
400
|
-
**
|
|
401
|
-
-
|
|
402
|
-
-
|
|
448
|
+
**Multi-project rule**
|
|
449
|
+
- Only one `project-state.md` should ever exist per context library. If a user has multiple projects, each project must have its own dedicated library — never mix two projects' state into one library.
|
|
450
|
+
- If a second `project-state.md` would need to be created in the same library, stop and ask the user to either use a different library or create a new one for this project.
|
|
403
451
|
|
|
404
452
|
**Project completion — convert to product description**
|
|
405
|
-
- When all phases in `project-
|
|
406
|
-
1. Ask the user: "All phases are complete — congratulations! Would you like me to convert the project
|
|
407
|
-
2. If yes: rewrite the content
|
|
408
|
-
3. If no: leave the
|
|
453
|
+
- When all phases in `project-state.md` are marked "Complete", automatically trigger the following:
|
|
454
|
+
1. Ask the user: "All phases are complete — congratulations! Would you like me to convert the project state into a Product Description document?"
|
|
455
|
+
2. If yes: rewrite the content in Contextium as a clean Product Description — summarise what was built, the decisions made (draw from the Decisions Log), the architecture or approach used, and outcomes. Remove phase status markers and the Decisions Log table. Title it "[Project Name] — Product Description". This document serves as a reference for future projects.
|
|
456
|
+
3. If no: leave the state file as-is and congratulate the user
|
|
409
457
|
- Never convert automatically without asking — always get confirmation first
|
|
410
458
|
</ongoing-project-rules>
|
|
@@ -34,72 +34,66 @@ Load the chosen workflow silently:
|
|
|
34
34
|
**MCP:** call mcp__contextium__load_workflow
|
|
35
35
|
</step>
|
|
36
36
|
|
|
37
|
-
<step name="
|
|
38
|
-
|
|
37
|
+
<step name="find_project_state">
|
|
38
|
+
Contextium is the source of truth. Always read from there first.
|
|
39
39
|
|
|
40
|
-
**1.
|
|
40
|
+
**1. Contextium first** — search the loaded workflow's libraries for `project-state.md`:
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
If found locally, use it. Show `→ Using local project plan (.ium-planning/project-plan.md)` and skip the Contextium lookup.
|
|
47
|
-
|
|
48
|
-
**2. Contextium fallback** — if not found locally, search the loaded workflow's libraries:
|
|
49
|
-
|
|
50
|
-
**CLI:** `contextium find "project-plan" -w <workspace> 2>/dev/null`
|
|
51
|
-
**MCP:** search list_files across the workflow's libraries for a file with path matching `project-plan.md`
|
|
42
|
+
**CLI:** `contextium find "project-state" -w <workspace> 2>/dev/null`
|
|
43
|
+
**MCP:** search list_files across the workflow's libraries for a file with path matching `project-state.md`
|
|
52
44
|
|
|
53
|
-
If found
|
|
45
|
+
If found, fetch the full content:
|
|
54
46
|
|
|
55
47
|
**CLI:** `contextium cat <fileId> -w <workspace> 2>/dev/null`
|
|
56
48
|
**MCP:** call mcp__contextium__get_file with the file ID
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
**2. Legacy fallback** — if `project-state.md` is not found, search for the older `project-plan.md` filename in the same libraries and treat it the same way.
|
|
59
51
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<fetched content>
|
|
63
|
-
EOF
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**3. Not found** — if the plan is in neither location, tell the user:
|
|
67
|
-
"No project plan found locally or in your Contextium workspace. If you set up this project with `/ium:new-project`, the plan should be in `.ium-planning/project-plan.md` or in one of your libraries. Would you like me to search the full workspace?"
|
|
52
|
+
**3. Not found** — if not found in Contextium, tell the user:
|
|
53
|
+
"No project state found in your Contextium workspace. If you set up this project with `/ium:new-project`, the state should be in one of your libraries. Would you like me to search the full workspace?"
|
|
68
54
|
</step>
|
|
69
55
|
|
|
70
|
-
<step name="
|
|
71
|
-
Read the project
|
|
56
|
+
<step name="parse_state">
|
|
57
|
+
Read the project state file and extract:
|
|
72
58
|
|
|
73
|
-
1.
|
|
74
|
-
2.
|
|
59
|
+
1. **Current Position** — from the `## Current Position` section: current phase name, status, and next action
|
|
60
|
+
2. **Handoff note** — look for a `> Session Handoff` block under the current phase. Contains what was completed, decisions made, what's needed next, open questions
|
|
75
61
|
3. **Completed phases** — all phases marked "Complete"
|
|
76
|
-
4. **Remaining phases** — all phases still "Not Started"
|
|
62
|
+
4. **Remaining phases** — all phases still "Not Started" or "In Progress"
|
|
63
|
+
5. **Recent decisions** — the last 3 entries from the `## Decisions Log` table (if it exists and has entries)
|
|
64
|
+
6. **Pending seeds** — any entries in the `## Seeds` table (surface only if relevant to the current phase)
|
|
77
65
|
|
|
78
66
|
Present a clear resumption brief:
|
|
79
67
|
|
|
80
68
|
```
|
|
81
69
|
── Resuming: [Project Name] ──────────────────────
|
|
82
70
|
|
|
83
|
-
Completed
|
|
71
|
+
Completed:
|
|
84
72
|
✓ Phase 1: [Name]
|
|
85
73
|
✓ Phase 2: [Name]
|
|
86
74
|
|
|
87
|
-
Current
|
|
75
|
+
Current:
|
|
88
76
|
→ Phase 3: [Name] — In Progress
|
|
77
|
+
Next action: [from Current Position]
|
|
89
78
|
|
|
90
79
|
Last session notes:
|
|
91
|
-
[Handoff note content]
|
|
80
|
+
[Handoff note content, or phase description if no handoff]
|
|
92
81
|
|
|
93
82
|
Up next:
|
|
94
|
-
[What the handoff says needs to happen
|
|
83
|
+
[What the handoff says needs to happen]
|
|
95
84
|
|
|
96
|
-
Remaining
|
|
85
|
+
Remaining:
|
|
97
86
|
○ Phase 4: [Name]
|
|
98
87
|
○ Phase 5: [Name]
|
|
99
88
|
|
|
89
|
+
Locked decisions:
|
|
90
|
+
• [Decision] — [Rationale]
|
|
91
|
+
• [Decision] — [Rationale]
|
|
92
|
+
|
|
100
93
|
─────────────────────────────────────────────────
|
|
101
94
|
```
|
|
102
95
|
|
|
96
|
+
Only show the "Locked decisions" section if the Decisions Log has entries — these are facts the session must not re-debate.
|
|
103
97
|
If no handoff note exists under the current phase, summarise the phase description instead.
|
|
104
98
|
</step>
|
|
105
99
|
|
|
@@ -113,21 +107,21 @@ Use AskUserQuestion:
|
|
|
113
107
|
- "Give me a summary of what we're building first"
|
|
114
108
|
- "I want to start a different phase"
|
|
115
109
|
|
|
116
|
-
If "Yes, let's go": activate the appropriate agent(s) from the loaded workflow and begin the phase work. Update the phase status in `project-
|
|
110
|
+
If "Yes, let's go": activate the appropriate agent(s) from the loaded workflow and begin the phase work. Update the phase status in `project-state.md` to "In Progress" if it isn't already.
|
|
117
111
|
|
|
118
112
|
If "Give me a summary": provide a concise overview of the full project and current phase goals drawn from the plan, then ask again if they're ready to continue.
|
|
119
113
|
|
|
120
|
-
If "I want to start a different phase": list the available phases and let them pick one. Update that phase to "In Progress" in `project-
|
|
114
|
+
If "I want to start a different phase": list the available phases and let them pick one. Update that phase to "In Progress" in `project-state.md`.
|
|
121
115
|
</step>
|
|
122
116
|
|
|
123
117
|
</process>
|
|
124
118
|
|
|
125
119
|
<rules>
|
|
126
120
|
- Never show raw file IDs, API responses, or CLI output to the user
|
|
127
|
-
- Always load the workflow before reading the project
|
|
128
|
-
- If the
|
|
129
|
-
- When continuing work, always update phase status in `project-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
- If all phases are marked "Complete" when reading the
|
|
121
|
+
- Always load the workflow before reading the project state — never search the full workspace without it
|
|
122
|
+
- If the state file has no handoff note, still resume gracefully using the phase description and Current Position
|
|
123
|
+
- When continuing work, always update `## Current Position` and phase status in `project-state.md` in Contextium
|
|
124
|
+
- Decisions in the `## Decisions Log` are locked — surface them in the resumption brief so the session starts with full context, but never re-debate them unless the user explicitly asks to
|
|
125
|
+
- At the end of each phase, follow the session usage check rule — if above 50%, write a new handoff note and update Current Position in Contextium, then prompt the user to start a fresh session with `/ium:resume-project`
|
|
126
|
+
- If all phases are marked "Complete" when reading the state, ask the user if they want to convert it into a Product Description document before resuming — do not start new phase work on a completed project without asking
|
|
133
127
|
</rules>
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ium:scan-existing
|
|
3
|
+
description: Scan an existing codebase and write analysis documents to a Contextium context library — tech stack, architecture, structure, conventions, and concerns. Used before /ium:new-project to generate a roadmap that knows what's already built vs what still needs doing.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Bash
|
|
6
|
+
- Glob
|
|
7
|
+
- Grep
|
|
8
|
+
- Read
|
|
9
|
+
- mcp__contextium__list_workspaces
|
|
10
|
+
- mcp__contextium__list_context_libraries
|
|
11
|
+
- mcp__contextium__list_workflows
|
|
12
|
+
- mcp__contextium__load_workflow
|
|
13
|
+
- mcp__contextium__create_context_library
|
|
14
|
+
- mcp__contextium__create_file
|
|
15
|
+
- mcp__contextium__update_file
|
|
16
|
+
- mcp__contextium__list_files
|
|
17
|
+
- mcp__contextium__get_file
|
|
18
|
+
- AskUserQuestion
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<objective>
|
|
22
|
+
Analyse an existing codebase across five domains and write the findings as structured documents to a Contextium context library. The output gives any agent full context about what exists, how it's built, and what's already working — without re-analysing the codebase every session. When followed by /ium:new-project, the roadmap will know what's already done and only plan phases for what's missing.
|
|
23
|
+
</objective>
|
|
24
|
+
|
|
25
|
+
<mode-detection>
|
|
26
|
+
Run once at the start, silently:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
command -v contextium &>/dev/null && echo "cli" || echo "no-cli"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- If `cli`: use CLI commands throughout.
|
|
33
|
+
- If `no-cli`: use MCP tools throughout.
|
|
34
|
+
- If neither: tell the user "Contextium doesn't appear to be installed." and stop.
|
|
35
|
+
</mode-detection>
|
|
36
|
+
|
|
37
|
+
<process>
|
|
38
|
+
|
|
39
|
+
<step name="check_auth">
|
|
40
|
+
**CLI only.** Run silently:
|
|
41
|
+
```bash
|
|
42
|
+
contextium whoami 2>/dev/null | grep -E "Token:|Name:" || echo "unauthenticated"
|
|
43
|
+
```
|
|
44
|
+
If unauthenticated or token expired, tell the user to run `contextium login` and stop.
|
|
45
|
+
|
|
46
|
+
MCP users are already authenticated — skip.
|
|
47
|
+
</step>
|
|
48
|
+
|
|
49
|
+
<step name="select_library">
|
|
50
|
+
Determine where to write the codebase documents.
|
|
51
|
+
|
|
52
|
+
If a workflow is already loaded in this session, check whether any of its libraries have an obvious "codebase" or "technical" purpose. If yes, suggest it. If not, ask which library to use.
|
|
53
|
+
|
|
54
|
+
If no workflow is loaded:
|
|
55
|
+
|
|
56
|
+
**CLI:** `contextium library list --workspace <slug> 2>/dev/null`
|
|
57
|
+
**MCP:** call mcp__contextium__list_context_libraries
|
|
58
|
+
|
|
59
|
+
Ask: "Which library should I write the codebase analysis to? Or I can create a new one — for example, 'Codebase Analysis'."
|
|
60
|
+
|
|
61
|
+
Use AskUserQuestion:
|
|
62
|
+
- Present existing library names
|
|
63
|
+
- "Create a new library for this"
|
|
64
|
+
|
|
65
|
+
If creating new: use the name the user provides, or default to "[Project Name] Codebase". Create it:
|
|
66
|
+
|
|
67
|
+
**CLI:** `contextium library create "<name>" --workspace <slug>`
|
|
68
|
+
**MCP:** call mcp__contextium__create_context_library
|
|
69
|
+
|
|
70
|
+
Store the target library ID as `target_library_id`.
|
|
71
|
+
</step>
|
|
72
|
+
|
|
73
|
+
<step name="check_existing">
|
|
74
|
+
Check whether any of the five analysis documents already exist in the target library by listing its files and looking for: `stack.md`, `architecture.md`, `structure.md`, `conventions.md`, `concerns.md`.
|
|
75
|
+
|
|
76
|
+
If any exist, ask:
|
|
77
|
+
|
|
78
|
+
"I found existing analysis documents in this library. What would you like to do?"
|
|
79
|
+
|
|
80
|
+
Use AskUserQuestion:
|
|
81
|
+
- "Refresh all documents (overwrite)"
|
|
82
|
+
- "Update specific documents only"
|
|
83
|
+
- "Cancel"
|
|
84
|
+
|
|
85
|
+
If "Update specific": ask which ones to update. Only run analysis passes for those.
|
|
86
|
+
If "Refresh all" or no existing docs: run all five passes.
|
|
87
|
+
</step>
|
|
88
|
+
|
|
89
|
+
<step name="orient">
|
|
90
|
+
Before analysing, silently orient yourself to the project. Run:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
ls -la 2>/dev/null | head -40
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Then look for the project's primary language and framework indicators:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
ls package.json requirements.txt Cargo.toml go.mod pyproject.toml composer.json 2>/dev/null
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
ls -d src/ app/ lib/ pkg/ internal/ api/ 2>/dev/null
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Do not show this output to the user. Use it to focus the analysis passes that follow.
|
|
107
|
+
|
|
108
|
+
Tell the user:
|
|
109
|
+
```
|
|
110
|
+
Scanning codebase — this will take a moment.
|
|
111
|
+
|
|
112
|
+
○ Tech stack & integrations
|
|
113
|
+
○ Architecture & structure
|
|
114
|
+
○ Conventions & testing
|
|
115
|
+
○ Concerns & tech debt
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Update each `○` to `✓` as each pass completes.
|
|
119
|
+
</step>
|
|
120
|
+
|
|
121
|
+
<step name="pass_1_tech">
|
|
122
|
+
**Tech Stack & Integrations**
|
|
123
|
+
|
|
124
|
+
Analyse and write `stack.md`:
|
|
125
|
+
|
|
126
|
+
Read dependency manifests:
|
|
127
|
+
```bash
|
|
128
|
+
cat package.json 2>/dev/null
|
|
129
|
+
cat requirements.txt pyproject.toml 2>/dev/null
|
|
130
|
+
cat Cargo.toml go.mod 2>/dev/null
|
|
131
|
+
cat composer.json 2>/dev/null
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Read config files:
|
|
135
|
+
```bash
|
|
136
|
+
cat tsconfig.json 2>/dev/null
|
|
137
|
+
ls *.config.* 2>/dev/null
|
|
138
|
+
cat .nvmrc .node-version .python-version 2>/dev/null
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Check for external service patterns:
|
|
142
|
+
```bash
|
|
143
|
+
grep -rn "process\.env\." src/ app/ lib/ 2>/dev/null | grep -v "node_modules" | head -40
|
|
144
|
+
cat .env.example .env.sample 2>/dev/null
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Produce `stack.md` in this structure:
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
# Tech Stack
|
|
151
|
+
**Analysis Date:** [today]
|
|
152
|
+
|
|
153
|
+
## Runtime & Language
|
|
154
|
+
[language, version, runtime]
|
|
155
|
+
|
|
156
|
+
## Frameworks & Libraries
|
|
157
|
+
[list key dependencies with versions and purpose]
|
|
158
|
+
|
|
159
|
+
## Build & Tooling
|
|
160
|
+
[build system, bundler, linter, formatter, type checker]
|
|
161
|
+
|
|
162
|
+
## External Services & Integrations
|
|
163
|
+
[APIs, databases, auth providers, storage, email — with env var names]
|
|
164
|
+
|
|
165
|
+
## Platform & Deployment
|
|
166
|
+
[inferred from config files — Docker, Vercel, Railway, etc.]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Every item must reference the actual config file or env var it was found in. No vague summaries.
|
|
170
|
+
|
|
171
|
+
Write to Contextium:
|
|
172
|
+
**CLI:** `cat << 'EOF' | contextium new <library-name> -t "Tech Stack" -p "stack.md" --stdin -w <workspace>`
|
|
173
|
+
**MCP:** call mcp__contextium__create_file (or update_file if refreshing)
|
|
174
|
+
|
|
175
|
+
Update the progress indicator to `✓ Tech stack & integrations`.
|
|
176
|
+
</step>
|
|
177
|
+
|
|
178
|
+
<step name="pass_2_architecture">
|
|
179
|
+
**Architecture & Structure**
|
|
180
|
+
|
|
181
|
+
Analyse and write `architecture.md` and `structure.md`:
|
|
182
|
+
|
|
183
|
+
Get the full directory tree:
|
|
184
|
+
```bash
|
|
185
|
+
find . -type f -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/.next/*" -not -path "*/build/*" | head -120
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Find entry points:
|
|
189
|
+
```bash
|
|
190
|
+
ls src/index.* src/main.* src/app.* src/server.* app/page.* app/layout.* 2>/dev/null
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Sample key files to understand patterns:
|
|
194
|
+
```bash
|
|
195
|
+
head -60 $(ls src/index.* src/main.* src/app.* 2>/dev/null | head -3) 2>/dev/null
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Produce `architecture.md`:
|
|
199
|
+
|
|
200
|
+
```markdown
|
|
201
|
+
# Architecture
|
|
202
|
+
**Analysis Date:** [today]
|
|
203
|
+
|
|
204
|
+
## Pattern
|
|
205
|
+
[MVC / layered / feature-based / monolith / microservices / etc — with evidence]
|
|
206
|
+
|
|
207
|
+
## Layers
|
|
208
|
+
[list each layer: what it contains, what it depends on, example files]
|
|
209
|
+
|
|
210
|
+
## Data Flow
|
|
211
|
+
[how a typical request flows through the system — entry point → handler → service → data layer]
|
|
212
|
+
|
|
213
|
+
## Key Abstractions
|
|
214
|
+
[important interfaces, base classes, shared utilities — with file paths]
|
|
215
|
+
|
|
216
|
+
## Error Handling
|
|
217
|
+
[how errors propagate — try/catch, result types, middleware, etc.]
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Produce `structure.md`:
|
|
221
|
+
|
|
222
|
+
```markdown
|
|
223
|
+
# Structure
|
|
224
|
+
**Analysis Date:** [today]
|
|
225
|
+
|
|
226
|
+
## Directory Map
|
|
227
|
+
[annotated directory tree showing purpose of each folder]
|
|
228
|
+
|
|
229
|
+
## Key File Locations
|
|
230
|
+
| Purpose | Path |
|
|
231
|
+
|---------|------|
|
|
232
|
+
| Entry point | `src/index.ts` |
|
|
233
|
+
| Route definitions | `src/routes/` |
|
|
234
|
+
| [etc] | [etc] |
|
|
235
|
+
|
|
236
|
+
## Where to Add New Code
|
|
237
|
+
[specific guidance: "New API routes go in src/routes/, follow the pattern in src/routes/users.ts"]
|
|
238
|
+
|
|
239
|
+
## Naming Conventions
|
|
240
|
+
[file naming, folder naming, component naming patterns with examples]
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Write both files to Contextium. Update progress to `✓ Architecture & structure`.
|
|
244
|
+
</step>
|
|
245
|
+
|
|
246
|
+
<step name="pass_3_conventions">
|
|
247
|
+
**Conventions & Testing**
|
|
248
|
+
|
|
249
|
+
Analyse and write `conventions.md` and `testing.md`:
|
|
250
|
+
|
|
251
|
+
Read linting/formatting config:
|
|
252
|
+
```bash
|
|
253
|
+
cat .eslintrc* eslint.config.* .prettierrc* biome.json 2>/dev/null
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Sample source files to extract conventions:
|
|
257
|
+
```bash
|
|
258
|
+
head -80 $(find src/ app/ lib/ -name "*.ts" -o -name "*.tsx" -o -name "*.js" 2>/dev/null | grep -v test | grep -v spec | head -5) 2>/dev/null
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Check testing setup:
|
|
262
|
+
```bash
|
|
263
|
+
cat jest.config.* vitest.config.* pytest.ini setup.cfg 2>/dev/null
|
|
264
|
+
find . -name "*.test.*" -o -name "*.spec.*" 2>/dev/null | grep -v node_modules | head -20
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Produce `conventions.md`:
|
|
268
|
+
|
|
269
|
+
```markdown
|
|
270
|
+
# Conventions
|
|
271
|
+
**Analysis Date:** [today]
|
|
272
|
+
|
|
273
|
+
## Naming
|
|
274
|
+
[variables, functions, classes, files, folders — with real examples from the codebase]
|
|
275
|
+
|
|
276
|
+
## Code Style
|
|
277
|
+
[formatting rules, import order, export patterns — reference linting config]
|
|
278
|
+
|
|
279
|
+
## Function Design
|
|
280
|
+
[pure vs stateful, async patterns, error handling style]
|
|
281
|
+
|
|
282
|
+
## State Management
|
|
283
|
+
[how state is managed — context, stores, props — with example file paths]
|
|
284
|
+
|
|
285
|
+
## Comments & Documentation
|
|
286
|
+
[what gets documented and how]
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Produce `testing.md`:
|
|
290
|
+
|
|
291
|
+
```markdown
|
|
292
|
+
# Testing
|
|
293
|
+
**Analysis Date:** [today]
|
|
294
|
+
|
|
295
|
+
## Framework & Setup
|
|
296
|
+
[test runner, assertion library, config file location]
|
|
297
|
+
|
|
298
|
+
## File Organisation
|
|
299
|
+
[where tests live relative to source — colocated, __tests__, etc.]
|
|
300
|
+
|
|
301
|
+
## Test Structure
|
|
302
|
+
[describe/it patterns, setup/teardown conventions — with example from an existing test]
|
|
303
|
+
|
|
304
|
+
## Mocking Approach
|
|
305
|
+
[how dependencies are mocked — with example]
|
|
306
|
+
|
|
307
|
+
## Coverage
|
|
308
|
+
[what's covered, what's not, any coverage thresholds configured]
|
|
309
|
+
|
|
310
|
+
## How to Run Tests
|
|
311
|
+
[exact commands]
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Write both files to Contextium. Update progress to `✓ Conventions & testing`.
|
|
315
|
+
</step>
|
|
316
|
+
|
|
317
|
+
<step name="pass_4_concerns">
|
|
318
|
+
**Concerns & Tech Debt**
|
|
319
|
+
|
|
320
|
+
Analyse and write `concerns.md`:
|
|
321
|
+
|
|
322
|
+
Find tech debt markers:
|
|
323
|
+
```bash
|
|
324
|
+
grep -rn "TODO\|FIXME\|HACK\|XXX\|TEMP\|@deprecated" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.py" . 2>/dev/null | grep -v node_modules | head -60
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Find large/complex files:
|
|
328
|
+
```bash
|
|
329
|
+
find . -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.py" 2>/dev/null | grep -v node_modules | grep -v dist | xargs wc -l 2>/dev/null | sort -rn | head -20
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Find empty stubs or incomplete implementations:
|
|
333
|
+
```bash
|
|
334
|
+
grep -rn "throw new Error.*not implemented\|TODO.*implement\|return null\|pass$" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.py" . 2>/dev/null | grep -v node_modules | head -30
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
Check for hardcoded values that should be config:
|
|
338
|
+
```bash
|
|
339
|
+
grep -rn "localhost\|127\.0\.0\.1\|hardcoded\|magic number" --include="*.ts" --include="*.js" . 2>/dev/null | grep -v node_modules | grep -v test | head -20
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Produce `concerns.md`:
|
|
343
|
+
|
|
344
|
+
```markdown
|
|
345
|
+
# Concerns & Tech Debt
|
|
346
|
+
**Analysis Date:** [today]
|
|
347
|
+
|
|
348
|
+
## Tech Debt
|
|
349
|
+
| Issue | Location | Suggested Fix |
|
|
350
|
+
|-------|----------|---------------|
|
|
351
|
+
| [specific issue] | `src/path/file.ts:42` | [concrete fix approach] |
|
|
352
|
+
|
|
353
|
+
## Known Gaps / Incomplete Features
|
|
354
|
+
[stubs, TODOs marked as incomplete, features with placeholder implementations — file paths required]
|
|
355
|
+
|
|
356
|
+
## Fragile Areas
|
|
357
|
+
[files or patterns that are high-risk to modify — explain why and how to modify safely]
|
|
358
|
+
|
|
359
|
+
## Security Observations
|
|
360
|
+
[anything that looks like a security concern — never log secrets, only note patterns]
|
|
361
|
+
|
|
362
|
+
## Test Coverage Gaps
|
|
363
|
+
[areas with no tests that clearly need them]
|
|
364
|
+
|
|
365
|
+
## Dependencies to Watch
|
|
366
|
+
[outdated, deprecated, or high-risk dependencies found in package manifest]
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Write to Contextium. Update progress to `✓ Concerns & tech debt`.
|
|
370
|
+
</step>
|
|
371
|
+
|
|
372
|
+
<step name="update_project_state">
|
|
373
|
+
If a `project-state.md` file exists in any library in the loaded workflow, read it and check the `## Phases` section.
|
|
374
|
+
|
|
375
|
+
For each phase whose described functionality clearly already exists in the codebase (based on what was found in the analysis), add a note under that phase:
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
> **Already built** — confirmed by codebase scan [date]
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
And update its status to "Complete" if the entire phase is done.
|
|
382
|
+
|
|
383
|
+
If no `project-state.md` exists yet, skip this step silently.
|
|
384
|
+
</step>
|
|
385
|
+
|
|
386
|
+
<step name="summary">
|
|
387
|
+
Show the final summary:
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
✓ Codebase scan complete
|
|
391
|
+
|
|
392
|
+
Documents written to "<library name>":
|
|
393
|
+
✓ stack.md — tech stack, dependencies, integrations
|
|
394
|
+
✓ architecture.md — patterns, layers, data flow
|
|
395
|
+
✓ structure.md — directory map, where to add new code
|
|
396
|
+
✓ conventions.md — naming, code style, patterns
|
|
397
|
+
✓ testing.md — test framework, structure, coverage
|
|
398
|
+
✓ concerns.md — tech debt, gaps, fragile areas
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Then ask:
|
|
402
|
+
|
|
403
|
+
"Would you like to set up a new project plan now? Running /ium:new-project will use these documents to understand what's already built and only plan phases for what's missing."
|
|
404
|
+
|
|
405
|
+
Use AskUserQuestion:
|
|
406
|
+
- "Yes, run /ium:new-project now"
|
|
407
|
+
- "No, I'll do it later"
|
|
408
|
+
|
|
409
|
+
If yes: proceed with the /ium:new-project flow. The codebase analysis documents are now in the library and will be found automatically when the project state is being planned.
|
|
410
|
+
</step>
|
|
411
|
+
|
|
412
|
+
</process>
|
|
413
|
+
|
|
414
|
+
<rules>
|
|
415
|
+
- Never show raw bash output, file paths, or API responses to the user — only the progress indicators and final summary
|
|
416
|
+
- Never read `.env` file contents — only check for the file's existence and read `.env.example` or `.env.sample`
|
|
417
|
+
- Every finding in every document must reference a specific file path — no vague summaries
|
|
418
|
+
- If a pass fails silently (no files found, permission error), write what was found and note "insufficient data to analyse [area]" — never skip the document entirely
|
|
419
|
+
- Documents are written for future AI agents to consume, not as human prose — be specific, prescriptive, and grounded in actual file paths
|
|
420
|
+
- When refreshing, always use update_file not create_file to preserve file history in Contextium
|
|
421
|
+
- Only one set of codebase analysis documents should exist per library — never create duplicates
|
|
422
|
+
</rules>
|