diff --git a/.claude/commands/continue.md b/.claude/commands/continue.md new file mode 100644 index 0000000..2e3dbd3 --- /dev/null +++ b/.claude/commands/continue.md @@ -0,0 +1,198 @@ +--- +name: "Continue" +description: Capture a full project status snapshot so the next session can continue seamlessly from where this one left off +category: Workflow +tags: [workflow, session, continuity, memory, snapshot] +--- + +Capture the full current project status and store it in persistent memory so the next session can pick up exactly where this one left off — no context lost, no recap needed. + +**Input**: No arguments required. Run `/continue` at any point when ending a session. + +--- + +**Steps** + +1. **Capture git state** + + Run the following in parallel: + ```bash + git status + git branch --show-current + git log --oneline -10 + git diff --stat HEAD + git stash list + ``` + + Record: + - Current branch name + - Uncommitted files (staged and unstaged), with change type (M/A/D/?) + - Last 10 commit messages (for continuity context) + - Summary of diff stats if uncommitted changes exist + - Any stashed work + +2. **Capture OpenSpec change state** + + Run `openspec list --json` to get all active changes. + + For each active (non-archived) change, run: + ```bash + openspec status --change "" --json + ``` + + For each active change, also read its `tasks.md` to count: + - Total tasks + - Completed tasks (`- [x]`) + - Pending tasks (`- [ ]`) + - The text of the next pending task (to know what's up next) + + Record per change: + - Change name + - Schema + - Artifact completion (which are done, which are pending) + - Task progress (X of Y complete) + - Next pending task description + - Any delta specs present (`openspec/changes//specs/`) + + **If no active changes:** Note that there are no active OpenSpec changes. + +3. **Capture in-session conversation context** + + Summarize what was worked on in this session based on the conversation: + - What was the user trying to accomplish? + - What was completed? + - What was left in-progress or blocked? + - Any key decisions made during this session + - Any open questions or next actions the user mentioned + + Keep this factual and brief — 3–8 bullet points. + +4. **Capture memory file state** + + Read `MEMORY.md` from the project memory directory: + `~/.claude/projects/-home-ubuntu-vj-ai-agents-dev-sentryagent-idp/memory/MEMORY.md` + + Note the existing memory entries to avoid duplication in the next step. + +5. **Write session snapshot to memory** + + Write a `session_snapshot.md` file to the project memory directory: + `~/.claude/projects/-home-ubuntu-vj-ai-agents-dev-sentryagent-idp/memory/session_snapshot.md` + + Use this structure: + + ```markdown + --- + name: Session Snapshot + description: Last session status — git state, OpenSpec progress, and conversation context for seamless resumption + type: project + --- + + **Session ended:** YYYY-MM-DD (today's date) + + ## Git State + + **Branch:** + **Uncommitted changes:** files () + **Last commit:** + + + + + + ## OpenSpec Changes + + + ### + - **Schema:** + - **Artifacts:** / complete () + - **Tasks:** / complete + - **Next task:** + - **Delta specs:** + + No active OpenSpec changes. + + ## Session Work + + + + ## Next Actions + + + ``` + + **IMPORTANT:** Always overwrite `session_snapshot.md` — this is a rolling snapshot, not a log. Only the most recent session state matters. + +6. **Update MEMORY.md index** + + Read the current `MEMORY.md`. If `session_snapshot.md` is not already listed, add it: + ``` + - [Session Snapshot](session_snapshot.md) — Last session: YYYY-MM-DD | branch: | active changes | uncommitted files + ``` + + If it is already listed, update the line to reflect today's date and current state. + + Write the updated `MEMORY.md`. + +7. **Display break summary** + + Show a clean summary so the user knows the snapshot is complete: + + ``` + ## Snapshot Saved — See You Next Session + + **Branch:** + **Uncommitted files:** () + **Active changes:** + + + - : / tasks complete — Next: "" + + **Session context saved to memory.** + + To resume: start a new session and run /continue — Claude will load the snapshot and pick up where you left off. + ``` + +--- + +**Output On Success (with active changes)** + +``` +## Snapshot Saved — See You Next Session + +**Branch:** develop +**Uncommitted files:** 3 (src/auth/token.ts, tests/auth.test.ts, README.md) +**Active changes:** 1 + +- add-agent-auth: 4/7 tasks complete — Next: "Implement JWT signing with RS256" + +**Session context saved to memory.** + +To resume: start a new session and run /continue — Claude will load the snapshot and pick up where you left off. +``` + +**Output On Success (clean state)** + +``` +## Snapshot Saved — See You Next Session + +**Branch:** main +**Uncommitted files:** 0 +**Active changes:** 0 + +**Session context saved to memory.** + +To resume: start a new session and run /continue — Claude will load the snapshot and pick up where you left off. +``` + +--- + +**Guardrails** + +- Always overwrite `session_snapshot.md` — do NOT append or create versioned copies +- Never include secrets, tokens, or credentials in the snapshot +- If `openspec list` fails (CLI not available), note that and skip OpenSpec capture gracefully +- If git is unavailable, note that and skip git capture gracefully +- Keep the session context summary factual — no speculation about future plans beyond what the user explicitly stated +- The MEMORY.md index line for `session_snapshot.md` must stay under 150 characters +- This command does NOT commit code, push branches, or modify any project files — it only writes to the memory directory diff --git a/.claude/commands/openspec-project-status.md b/.claude/commands/openspec-project-status.md new file mode 100644 index 0000000..db68a51 --- /dev/null +++ b/.claude/commands/openspec-project-status.md @@ -0,0 +1,160 @@ +--- +name: "OpenSpec Project Status" +description: Show a human-readable summary of all OpenSpec changes — active, archived, artifact completion, and task progress +category: Workflow +tags: [workflow, status, openspec, reporting] +--- + +Show the full OpenSpec project status in a clear, human-readable format. No raw JSON — just a clean picture of where the project stands. + +**Input**: No arguments required. Run `/openspec-project-status` at any time. + +--- + +**Steps** + +1. **Get all changes** + + Run: + ```bash + openspec list --json + ``` + + Separate results into: + - **Active changes** (not in `archive/`) + - **Archived changes** (in `archive/`) + + If the command fails or no changes exist, display a friendly empty state (see Output section). + +2. **For each active change, gather full status** + + Run in parallel for all active changes: + ```bash + openspec status --change "" --json + ``` + + Also read each change's `tasks.md` to extract: + - Total task count + - Completed tasks (`- [x]`) + - Pending tasks (`- [ ]`) + - Text of the **next pending task** (first `- [ ]` item) + + Also check for delta specs at `openspec/changes//specs/` — note if present. + +3. **For archived changes** + + List them by archive date (newest first). No need to read full status — just show name and archive date from the folder name (`YYYY-MM-DD-`). + +4. **Render the human-readable status report** + + Use the output format defined below. + +--- + +**Output Format** + +``` +## OpenSpec Project Status + +### Active Changes () + +──────────────────────────────────────── + +──────────────────────────────────────── + Schema: + Phase: + + Artifacts + ✓ proposal done + ✓ design done + ◌ tasks pending + + Tasks / complete + ████████░░░░░░░░ 50% + Next: "" + + Delta Specs + +──────────────────────────────────────── + + + +--- + +### Archived Changes () + + 2026-03-20 add-initial-auth + 2026-03-15 setup-ci-pipeline + 2026-03-10 scaffold-project + +--- + +### Summary + + Active changes: + Ready to apply: (all artifacts done, tasks pending) + In progress: (tasks partially complete) + Complete: (all tasks done, not yet archived) + Archived: +``` + +**Phase inference rules** (from artifact + task state): +- `Proposing` — proposal artifact is not done +- `Designing` — proposal done, design not done +- `Speccing` — design done, tasks artifact not done +- `Ready to Implement` — all artifacts done, 0 tasks complete +- `In Progress` — all artifacts done, some tasks complete but not all +- `Complete` — all artifacts done, all tasks complete (not yet archived) + +**Progress bar rules:** +- 16 chars wide: `█` per completed segment, `░` for remaining +- Show percentage after bar +- If 0 tasks: show `No tasks yet` +- If all tasks done: show `████████████████ 100% All done!` + +--- + +**Output: No active changes** + +``` +## OpenSpec Project Status + +### Active Changes (0) + + No active changes. Start one with /opsx:propose + +--- + +### Archived Changes () + + 2026-03-20 add-initial-auth + ... + +--- + +### Summary + + Active changes: 0 + Archived: +``` + +**Output: OpenSpec CLI unavailable** + +``` +## OpenSpec Project Status + + OpenSpec CLI not available. Cannot read change data. + + Make sure `openspec` is installed and accessible in your PATH. +``` + +--- + +**Guardrails** + +- Never show raw JSON — always translate to human-readable output +- Never guess artifact or task state — always read from actual files and CLI output +- If a `tasks.md` file does not exist for a change, show `No tasks file` instead of 0/0 +- Archived changes are display-only — never modify them +- Phase labels must be inferred strictly from actual artifact + task state, not assumed +- If `openspec status` fails for a specific change, show that change with `Status unavailable` and continue diff --git a/.claude/commands/opsx/apply.md b/.claude/commands/opsx/apply.md new file mode 100644 index 0000000..bf23721 --- /dev/null +++ b/.claude/commands/opsx/apply.md @@ -0,0 +1,152 @@ +--- +name: "OPSX: Apply" +description: Implement tasks from an OpenSpec change (Experimental) +category: Workflow +tags: [workflow, artifacts, experimental] +--- + +Implement tasks from an OpenSpec change. + +**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. + +**Steps** + +1. **Select the change** + + If a name is provided, use it. Otherwise: + - Infer from conversation context if the user mentioned a change + - Auto-select if only one active change exists + - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select + + Always announce: "Using change: " and how to override (e.g., `/opsx:apply `). + +2. **Check status to understand the schema** + ```bash + openspec status --change "" --json + ``` + Parse the JSON to understand: + - `schemaName`: The workflow being used (e.g., "spec-driven") + - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others) + +3. **Get apply instructions** + + ```bash + openspec instructions apply --change "" --json + ``` + + This returns: + - Context file paths (varies by schema) + - Progress (total, complete, remaining) + - Task list with status + - Dynamic instruction based on current state + + **Handle states:** + - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` + - If `state: "all_done"`: congratulate, suggest archive + - Otherwise: proceed to implementation + +4. **Read context files** + + Read the files listed in `contextFiles` from the apply instructions output. + The files depend on the schema being used: + - **spec-driven**: proposal, specs, design, tasks + - Other schemas: follow the contextFiles from CLI output + +5. **Show current progress** + + Display: + - Schema being used + - Progress: "N/M tasks complete" + - Remaining tasks overview + - Dynamic instruction from CLI + +6. **Implement tasks (loop until done or blocked)** + + For each pending task: + - Show which task is being worked on + - Make the code changes required + - Keep changes minimal and focused + - Mark task complete in the tasks file: `- [ ]` → `- [x]` + - Continue to next task + + **Pause if:** + - Task is unclear → ask for clarification + - Implementation reveals a design issue → suggest updating artifacts + - Error or blocker encountered → report and wait for guidance + - User interrupts + +7. **On completion or pause, show status** + + Display: + - Tasks completed this session + - Overall progress: "N/M tasks complete" + - If all done: suggest archive + - If paused: explain why and wait for guidance + +**Output During Implementation** + +``` +## Implementing: (schema: ) + +Working on task 3/7: +[...implementation happening...] +✓ Task complete + +Working on task 4/7: +[...implementation happening...] +✓ Task complete +``` + +**Output On Completion** + +``` +## Implementation Complete + +**Change:** +**Schema:** +**Progress:** 7/7 tasks complete ✓ + +### Completed This Session +- [x] Task 1 +- [x] Task 2 +... + +All tasks complete! You can archive this change with `/opsx:archive`. +``` + +**Output On Pause (Issue Encountered)** + +``` +## Implementation Paused + +**Change:** +**Schema:** +**Progress:** 4/7 tasks complete + +### Issue Encountered + + +**Options:** +1.