- name
- archive-logs
- description
- Archive Claude Code conversation logs into the current project as JSONL and readable Markdown
- disable-model-invocation
- true
Archive the Claude Code conversation logs from this project into the project itself, for auditability and transparency.
## Workflow
1. **Find logs**: Look in `~/.claude/projects/<encoded-path>/` where the encoded path replaces `/` with `-` in the current working directory path. List `*.jsonl` files (top-level only, not subdirectories).
2. **Identify sessions**: For each JSONL, extract the first user message to understand the session topic. Skip files with 0 user messages. Assign descriptive numbered names (e.g. `01_initial_setup.jsonl`, `02_feature_work.jsonl`).
3. **Check for duplicates**: If `logs/conversation/` already exists, compare against existing files to avoid re-archiving.
4. **Copy JSONL files** into `logs/conversation/` in the project.
5. **Create a converter script** at `scripts/jsonl_to_markdown.py` that converts JSONL to readable Markdown. The JSONL format:
- Each line is a JSON object with a `type` field
- Types `user` and `assistant` contain `message.content` (string or array of content blocks)
- Content block types: `text` (render), `tool_use` (show tool name + concise input), `tool_result` (abbreviate), `thinking` (omit)
- Filter out `<system-reminder>` tags from user messages
- Skip tool_result-only user messages
6. **Run the converter** to generate `.md` files alongside the `.jsonl` files.
7. **Scan for secrets**: Install `detect-secrets` (`uv add --dev detect-secrets` or ensure it's available), then run `detect-secrets scan logs/conversation/` on all archived files (both `.jsonl` and `.md`). If any secrets are detected:
- Print a clear warning listing each file and the line number(s) flagged.
- Do NOT commit the files. Instead, ask the user how to proceed (redact, skip the file, or abort).
- Secrets often appear in bash tool stdout/stderr in the JSONL. Common sources: `echo $API_KEY`, env variable dumps, credential outputs.
8. **Write `logs/conversation/README.md`** listing each session.
9. **Report** what was archived (and whether the secret scan passed cleanly).
Voir sur GitHub