| name | cc-trace |
| description | Generates a Context Snapshot (Why/rationale + file changes) before /compact to preserve important decision history across Claude Code sessions. Use when running /compact or when you need to save session context. Hooks auto-intercept both manual and auto-compact.
|
| aliases | ["cct"] |
| license | MIT |
cctrace โ Context Snapshot Skill
Saves the "Why" behind technical decisions before /compact wipes the conversation history.
Commands
| Command | Description |
|---|
cctrace:init | Set up cctrace for the current project (hooks + .cctrace/ dir) |
cctrace:run | Manually generate a Context Snapshot now |
cctrace:config | View/change cctrace configuration |
cctrace:status | Show freshness and snapshot history |
cctrace:list | List all saved snapshots |
cctrace:load | Inject a saved snapshot into the current session |
cctrace:reset | Force re-generation before next /compact |
cctrace:init
Purpose: Set up cctrace for the current project.
Steps
-
Check that ~/.claude/skills/cctrace/ exists. If not, tell the user to install cctrace first:
cp -r <dev-path>/cc-context ~/.claude/skills/cctrace
chmod +x ~/.claude/skills/cctrace/hooks/*.sh
The hook entrypoints remain .sh for Claude hook compatibility, but delegate to the adjacent .nu implementations. Install Nushell and ensure nu is on PATH before enabling the hooks.
-
Create .cctrace/ directory in the current working directory.
-
Create .cctrace/config.json with defaults:
{
"model": "claude-sonnet-4-6",
"detail_level": "full",
"proactive_threshold": null
}
-
Use AskUserQuestion to confirm .gitignore update:
- Options: [่ฟฝ่จใใ, ในใญใใใใ]
- If confirmed: append
.cctrace/ to .gitignore (create if it doesn't exist)
-
Use AskUserQuestion to choose where to register hooks:
- Option A:
~/.claude/settings.json (ๅ
จใใญใธใงใฏใๅ
ฑ้ใปๆจๅฅจ)
- Option B:
.claude/settings.json (ใใฎใใญใธใงใฏใใฎใฟ)
-
Read the chosen settings.json. Parse it carefully, then append the 5 hooks under "hooks" key.
Important: Do NOT replace existing hooks โ only add the cctrace entries.
Use python3 or jq to safely merge JSON rather than overwriting.
Hooks to add:
{
"PreCompact": [
{
"matcher": "manual",
"hooks": [{ "type": "command", "command": "~/.claude/skills/cctrace/hooks/precompact-manual.sh", "timeout": 10 }]
},
{
"matcher": "auto",
"hooks": [{ "type": "command", "command": "~/.claude/skills/cctrace/hooks/precompact-auto.sh", "timeout": 120 }]
}
],
"PostCompact": [
{ "hooks": [{ "type": "command", "command": "~/.claude/skills/cctrace/hooks/postcompact.sh", "timeout": 10 }] }
],
"SessionStart": [
{ "hooks": [{ "type": "command", "command": "~/.claude/skills/cctrace/hooks/session-start.sh", "timeout": 15 }] }
],
"UserPromptSubmit": [
{ "hooks": [{ "type": "command", "command": "~/.claude/skills/cctrace/hooks/user-prompt-submit.sh", "timeout": 5 }] }
]
}
-
Show completion summary: what was created, where hooks were registered.
cctrace:run
Purpose: Generate a Context Snapshot from the current session's conversation.
The transcript path is injected into your context by the UserPromptSubmit hook as:
[cctrace] transcript_path: /path/to/transcript.jsonl
Steps
-
Check if .cctrace/latest-summary.md already exists.
- If exists: use AskUserQuestion โ [ไธๆธใ็ๆใใ, ใญใฃใณใปใซ]
- If not exists: use AskUserQuestion โ [็ๆใใ, ใญใฃใณใปใซ]
- If cancelled: stop.
-
Get the transcript path from the injected context ([cctrace] transcript_path: ...).
- If not found, look for the most recent
.jsonl in ~/.claude/projects/ matching the current CWD.
-
Get the model from .cctrace/config.json (default: claude-sonnet-4-6).
-
Run the transcript processor to build a structured prompt:
python3 ~/.claude/skills/cctrace/scripts/process_transcript.py \
"<transcript_path>" \
"<cwd>" \
"<detail_level>"
The script outputs a prompt string to stdout.
-
Pipe the prompt to claude CLI:
python3 ~/.claude/skills/cctrace/scripts/process_transcript.py \
"<transcript_path>" "<cwd>" "<detail_level>" \
| claude -p --model <model>
Capture the output as the summary content.
-
Write the summary:
- Archive:
.cctrace/YYYY-MM-DD-HHmmss.md
- Latest:
.cctrace/latest-summary.md
-
Confirm: "โ cctrace ในใใใใทใงใใใไฟๅญใใพใใ: .cctrace/latest-summary.md"
cctrace:config
Purpose: View and edit cctrace settings.
Steps
-
Read .cctrace/config.json. If not found, suggest running cctrace:init first.
-
Display current settings in a formatted block.
-
Use AskUserQuestion (multi-select): ใฉใฎ่จญๅฎใๅคๆดใใพใใ๏ผ
- model๏ผAI ใขใใซ๏ผ
- detail_level๏ผminimal / full๏ผ
- proactive_threshold๏ผใณใณใใญในใไฝฟ็จ็ %, null ใง็กๅน๏ผ
- ๅคๆดใใชใ
-
For each selected item, prompt for new value via AskUserQuestion.
-
Write updated config to .cctrace/config.json.
cctrace:status
Purpose: Show the current state of cctrace in this project.
Steps
-
Check if .cctrace/ exists. If not, suggest cctrace:init.
-
Collect and display:
โโ cctrace status โโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ latest-summary.md: 2026-07-13 10:30 (3.2 KB)
๐ last compact: 2026-07-13 09:55
โ
freshness: FRESH (summary is newer than last compact)
๐ฆ archives: 5 snapshots in .cctrace/
โ๏ธ model: claude-sonnet-4-6 | detail: full
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
Freshness logic:
- FRESH โ
if
latest-summary.md mtime > .last-compact-at mtime (or .last-compact-at doesn't exist)
- STALE โ ๏ธ otherwise
- MISSING โ if
latest-summary.md doesn't exist
cctrace:list
Purpose: List all saved Context Snapshots.
Steps
-
List all .md files in .cctrace/ excluding latest-summary.md.
Sort by filename (newest first).
-
For each file, show:
- Filename (timestamp)
- File size
- First non-frontmatter line (title or first heading)
-
If no archives: "ใขใผใซใคใใใใใพใใใcctrace:run ใงๆๅใฎในใใใใทใงใใใไฝๆใใฆใใ ใใใ"
cctrace:load
Purpose: Inject a saved snapshot into the current session context.
Steps
-
If no argument: load latest-summary.md.
If argument provided (number or date string): find the matching archive in .cctrace/.
-
Read the snapshot file.
-
Output the full content as a visible block with header:
โโ cctrace: Loaded Context Snapshot โโโโโโโโโ
[snapshot content]
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
Confirm: "โ ในใใใใทใงใใใ็พใปใใทใงใณใซ่ชญใฟ่พผใฟใพใใใ"
cctrace:reset
Purpose: Force re-generation of a snapshot before the next /compact.
Steps
-
Use AskUserQuestion:
".last-compact-at ใๅ้คใใฆๆฌกใฎ /compact ใง cctrace:run ใๅผทๅถใใพใใ๏ผ"
Options: [ใชใปใใใใ, ใญใฃใณใปใซ]
-
If confirmed: delete .cctrace/.last-compact-at.
-
Confirm: "โ ใชใปใใๅฎไบใๆฌกใฎ /compact ๆใซ cctrace:run ใๅฟ
่ฆใซใชใใพใใ"
Notes for All Commands
- CWD: Always use the project's working directory (where
.cctrace/ lives).
- Config fallback: If
.cctrace/config.json is missing, use defaults silently.
- Error handling: If any Bash command fails, explain what happened and suggest
cctrace:init.
- Transcript path: Injected by UserPromptSubmit hook as
[cctrace] transcript_path: <path>