Skip to content

Commit 4d4691e

Browse files
committed
feat: add Claude Code slash commands and CLI tests
- Add .claude/commands/ with ctx slash commands for Claude Code - Update command templates with improved descriptions - Add comprehensive tests for CLI and embed packages - Archive completed tasks and update task list - Minor fixes to add.go and compact.go Signed-off-by: Jose Alekhinne <alekhinejose@gmail.com>
1 parent cbeb581 commit 4d4691e

23 files changed

Lines changed: 1927 additions & 134 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: "Add a decision to DECISIONS.md"
3+
argument-hint: "\"decision text\""
4+
---
5+
6+
```!
7+
ctx add decision $ARGUMENTS
8+
```
9+
10+
Confirm the decision was added.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: "Add a learning to LEARNINGS.md"
3+
argument-hint: "\"learning text\""
4+
---
5+
6+
```!
7+
ctx add learning $ARGUMENTS
8+
```
9+
10+
Confirm the learning was added.

.claude/commands/ctx-add-task.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: "Add a task to TASKS.md"
3+
argument-hint: "\"task text\""
4+
---
5+
6+
```!
7+
ctx add task $ARGUMENTS
8+
```
9+
10+
Confirm the task was added.

.claude/commands/ctx-agent.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: "Get AI-ready context packet"
3+
argument-hint: "[--budget N]"
4+
---
5+
6+
Load the full context packet for AI consumption.
7+
8+
**Usage:**
9+
```
10+
/ctx-agent
11+
/ctx-agent --budget 4000
12+
/ctx-agent --budget 8000
13+
```
14+
15+
Returns context optimized for AI assistants. Use `--budget` to limit token count.
16+
17+
```!
18+
ctx agent $ARGUMENTS
19+
```
20+
21+
This provides the complete context state optimized for AI assistants.

.claude/commands/ctx-archive.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
description: "Archive completed tasks"
3+
argument-hint: "[--dry-run]"
4+
---
5+
6+
Move completed tasks from TASKS.md to the archive.
7+
8+
**Usage:**
9+
```
10+
/ctx-archive
11+
/ctx-archive --dry-run
12+
```
13+
14+
Moves completed `[x]` tasks to `.context/archive/`. Use `--dry-run` to preview.
15+
16+
```!
17+
ctx tasks archive $ARGUMENTS
18+
```
19+
20+
Report how many tasks were archived.

.claude/commands/ctx-loop.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: "Generate a Ralph loop script"
3+
argument-hint: "[--tool claude|aider] [--prompt FILE] [--max-iterations N]"
4+
---
5+
6+
Generate a ready-to-use Ralph loop shell script.
7+
8+
**Usage:**
9+
```
10+
/ctx-loop
11+
/ctx-loop --tool aider
12+
/ctx-loop --prompt PROMPT.md --max-iterations 10
13+
```
14+
15+
Generates a shell script for iterative AI development. Defaults to Claude Code.
16+
17+
```!
18+
ctx loop $ARGUMENTS
19+
```
20+
21+
Report the generated script path and how to run it.

.claude/commands/ctx-save.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
description: "Save current context to a session file"
3+
argument-hint: "[topic]"
4+
---
5+
6+
Save the current context state to `.context/sessions/`.
7+
8+
**Usage:**
9+
```
10+
/ctx-save
11+
/ctx-save auth-refactor
12+
/ctx-save "database migration"
13+
```
14+
15+
Saves session to `.context/sessions/YYYY-MM-DD-<topic>.md`. Topic is optional.
16+
17+
```!
18+
ctx session save $ARGUMENTS
19+
```
20+
21+
Report the saved session file path to the user.

.claude/commands/ctx-status.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: "Show context summary"
3+
---
4+
5+
Show the current context status.
6+
7+
```!
8+
ctx status
9+
```
10+
11+
Summarize the context state for the user.

.context/TASKS.md

Lines changed: 10 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,17 @@
11
# Tasks — Context CLI
22

3-
### Phase 1: Project Scaffolding `#priority:high` `#area:setup`
4-
- [x] Initialize Go module (`go mod init github.com/ActiveMemory/ctx`)
5-
- [x] Create directory structure (cmd/ctx, internal/cli, internal/context, internal/templates)
6-
- [x] Set up Cobra CLI skeleton in cmd/ctx/main.go
7-
- [x] Add dependencies (cobra, color, yaml)
3+
## In Progress
84

9-
### Phase 2: Core Commands `#priority:high` `#area:cli`
10-
- [x] Implement `ctx init` — create .context/ with template files
11-
- [x] Implement `ctx status` — show context summary
12-
- [x] Implement `ctx agent` — print AI-ready context packet
13-
- [x] Implement `ctx load` — output assembled context
5+
## Next Up
146

15-
### Phase 3: Context Operations `#priority:high` `#area:cli`
16-
- [x] Implement `ctx add` — add decision/task/learning
17-
- [x] Implement `ctx complete` — mark task done
18-
- [x] Implement `ctx drift` — detect stale context
19-
- [x] Implement `ctx sync` — reconcile with codebase
7+
- [ ] Enforce test coverage targets in CI/Makefile #priority:medium #area:quality
8+
- internal/cli: 60% (currently 62.8%)
9+
- internal/context: 80% (currently 86.8%)
10+
- internal/drift: 80% (currently 88.0%)
11+
- internal/claude: 80% (currently 87.5%)
12+
- internal/templates: 80% (currently 88.9%)
2013

21-
### Phase 4: Maintenance Commands `#priority:medium` `#area:cli`
22-
- [x] Implement `ctx compact` — archive old items
23-
- [x] Implement `ctx watch` — watch for update commands
24-
- [x] Implement `ctx watch --auto-save` mode
25-
- [x] Implement `ctx hook` — generate tool config
26-
27-
### Phase 5: Session Management `#priority:medium` `#area:cli`
28-
- [x] Implement `ctx session save` — manually dump context to sessions/
29-
- [x] Implement `ctx session list` — list saved sessions with summaries
30-
- [x] Implement `ctx session load <file>` — load/summarize a previous session
31-
- [x] Implement `ctx session parse` — convert .jsonl transcript to readable markdown
32-
- [x] Add `--extract` flag to session parse — extract decisions/learnings from transcript
33-
34-
### Phase 6: Claude Code Integration `#priority:high` `#area:integration`
35-
- [x] Create `.context/sessions/` directory structure
36-
- [x] Create CLAUDE.md for native Claude Code bootstrapping
37-
- [x] Set up PreToolUse hook for auto-load
38-
- [x] Set up SessionEnd hook for auto-save
39-
- [x] Enhance `ctx init` to create Claude hooks (embedded scripts, settings.local.json)
40-
- [x] Handle CLAUDE.md creation/merge in `ctx init` (backup, markers, --merge flag)
41-
- [x] Add PATH check to `ctx init` — verify ctx is in PATH before creating hooks
42-
- [x] Document session persistence in AGENT_PLAYBOOK.md
43-
44-
### Phase 7: Testing & Verification `#priority:high` `#area:quality`
45-
- [x] Add headers to all files
46-
- [x] Add integration tests — invoke actual binary, verify output
47-
- [x] `ctx init` creates expected files
48-
- [x] `ctx status` returns valid status (not just help text)
49-
- [x] `ctx add learning "test"` modifies LEARNINGS.md
50-
- [x] `ctx session save` creates session file
51-
- [x] `ctx agent` returns context packet
52-
- [x] Set unit test coverage target (70% for internal/cli, internal/context)
53-
- [x] Add coverage reporting to `make test`
54-
- [x] Add smoke test to CI/Makefile: build binary, run basic commands
55-
- [x] Verify built binary executes subcommands (not silently falling through to root help)
56-
57-
### Phase 8: Task Archival & Snapshots `#priority:medium` `#area:cli`
58-
- [x] Implement `ctx tasks archive` — move completed tasks to timestamped archive file
59-
- [x] Implement `ctx tasks snapshot` — create point-in-time snapshot of TASKS.md
60-
- [x] Archive location: `.context/archive/tasks-YYYY-MM-DD.md`
61-
- [x] Keep Phase structure in archives for traceability
62-
- [x] Update CONSTITUTION.md: archival is allowed, deletion is not
63-
64-
### Phase 9: Claude Slash Commands (Skills) `#priority:medium` `#area:cli`
65-
- [x] Research how existing skills are registered (check ralph-loop pattern)
66-
- [x] Create `/ctx-save` skill — calls `ctx session save`
67-
- [x] Create `/ctx-status` skill — calls `ctx status`
68-
- [x] Create `/ctx-add-learning` skill — calls `ctx add learning`
69-
- [x] Create `/ctx-add-decision` skill — calls `ctx add decision`
70-
- [x] Create `/ctx-add-task` skill — calls `ctx add task`
71-
- [x] Create `/ctx-agent` skill — calls `ctx agent` (manual context load)
72-
- [x] Create `/ctx-archive` skill — calls `ctx tasks archive`
73-
- [x] Create `/ctx-loop` skill — calls `ctx loop` (generate Ralph loop script)
74-
- [x] Update `ctx init` to create skill definitions in `.claude/commands/`
75-
76-
### Phase 9b: Ralph Loop Integration `#priority:medium` `#area:cli`
77-
- [x] Implement `ctx loop` command — generate a ready-to-use loop.sh script
78-
- [x] Detect AI tool in use (claude, aider, etc.) and generate appropriate invocation
79-
- [x] Include configurable max iterations, prompt file path
80-
- [x] Include completion signal detection (SYSTEM_CONVERGED, SYSTEM_BLOCKED)
81-
- [x] Make script executable by default
82-
- [x] Add `ctx loop --prompt PROMPT.md` — specify custom prompt file
83-
- [x] Add `ctx loop --tool claude|aider|generic` — target specific AI CLI
84-
- [x] Document in README that `/ralph-loop` exists for Claude Code users
85-
86-
### Phase 10: Project Rename `#priority:medium` `#area:branding`
87-
- [x] Rename project from "Active Memory" to "Context"
88-
- [x] Update README.md title and references
89-
- [x] Update Go module path (github.com/ActiveMemory/ctx)
90-
- [x] Update all import paths in Go files
91-
- [x] Update CLAUDE.md references
92-
- [x] Keep `ctx` as binary name (short for context)
93-
- [x] Handle GitHub repo rename (manual step)
94-
95-
### Phase 11: Documentation `#priority:low` `#area:docs`
96-
- [x] Document Claude Code integration in README
97-
- [x] Add "Dogfooding Guide" — how to use ctx on ctx itself
98-
- [x] Document session auto-save setup for new users
99-
- [x] Create actual documentation site in `docs/` folder
100-
- [x] Getting started guide
101-
- [x] CLI command reference
102-
- [x] Context file format reference
103-
- [x] Integration guides (Claude Code, Cursor, Aider, etc.)
104-
- [x] Ralph Loop pairing guide
105-
- [x] Set up Cloudflare Pages to serve docs at ctx.ist
106-
- [x] Review docs/ and README.md for accuracy and completeness `#human-in-the-loop`
107-
- Verify CLI examples work as documented
108-
- Check for inconsistencies between README.md and docs/
109-
- Requires human confirmation before marking complete
110-
- [x] Simplify README.md to direct users to ctx.ist
111-
- Keep minimal intro + installation + quick start
112-
- Link to full docs at ctx.ist for details
113-
- Reduced from ~620 lines to ~110 lines
14+
## Completed (Recent)
11415

11516
## Blocked
11617

@@ -130,17 +31,4 @@
13031
- `[-]` — skipped (with reason)
13132
- `#in-progress` — currently being worked on (add inline, don't move task)
13233

133-
### Phase 12: Timestamp-Based Session Correlation `#priority:medium` `#area:cli`
134-
- [x] Add timestamp to formatTask() in add.go — currently tasks have no timestamp, add `#added:YYYY-MM-DD-HHMM` or similar
135-
- [x] Increase timestamp precision in formatLearning() — change from YYYY-MM-DD to YYYY-MM-DD-HHMM
136-
- [x] Increase timestamp precision in formatDecision() — change from YYYY-MM-DD to YYYY-MM-DD-HHMM
137-
- [x] Add start_time field to session summary files — record when session began
138-
- [-] Add last_update_time field to session summary files — skipped: end_time provides session bounds; tracking live updates requires state persistence
139-
- [x] Document timestamp correlation approach in AGENT_PLAYBOOK.md — explain how to correlate entries to sessions by time overlap
140-
141-
### Phase 13: Rich Context Entries `#priority:medium` `#area:cli`
142-
- [x] Add --file flag to ctx add — read entry content from a file instead of CLI arg
143-
- [x] Add stdin support to ctx add — if no content arg and stdin is pipe, read from stdin
144-
- [x] Create learning template with Context/Lesson/Application structure for --file usage
145-
- [x] Create decision template with Context/Options/Decision/Rationale structure for --file usage
146-
- [x] Document rich entry workflow in AGENT_PLAYBOOK.md — explain when/how agents should use --file vs inline
34+
**Archives**: See `.context/archive/` for completed tasks from previous phases.

0 commit comments

Comments
 (0)