chat-history
Extract and organize Claude Code session history into project .chats directory. Use when users want to document their Claude sessions, export conversation inputs, or maintain a log of instructions given to Claude.
What this skill does
# Chat History Extractor
Extract user inputs from Claude Code session history (`~/.claude/projects/`) and organize them into a project's `.chats` directory with daily markdown files.
## When to Use This Skill
Use this skill when the user wants to:
- **Extract session history** from Claude Code sessions
- **Document conversations** for future reference
- **Create instruction logs** organized by date
- **Export user inputs** from `.jsonl` session files
- **Maintain a changelog** of Claude interactions
## How It Works
Claude Code stores session data in `~/.claude/projects/{project-path-encoded}/` as `.jsonl` files. Each file contains messages with:
- `type: "user"` - User messages
- `userType: "external"` - External user (not system/agent)
- `message.content` - The actual message content
This skill extracts meaningful user instructions (filtering out system commands, tool results, and session continuations) and organizes them by date into `.chats/{YYYYMMDD}.md` files.
## Instructions
### Step 1: Identify the Project Session Directory
The session directory is derived from the current working directory path:
- Replace `/` with `-` in the path
- Prefix with `-`
- Location: `~/.claude/projects/{encoded-path}/`
```bash
# Example: /Users/tchen/projects/tubi/titc
# Becomes: -Users-tchen-projects-tubi-titc
# Full path: ~/.claude/projects/-Users-tchen-projects-tubi-titc/
```
### Step 2: Find Session Files by Date
List session files and filter by modification date:
```bash
# List all main session files (excluding agent-* files) for a specific date
ls -la ~/.claude/projects/{project-dir}/*.jsonl | grep "Dec 25" | grep -v agent-
```
### Step 3: Extract User Inputs
Extract user messages from jsonl files using jq:
```bash
cat {session-file}.jsonl | jq -r '
select(.type == "user" and .userType == "external" and (.isMeta | not)) |
.message.content |
if type == "string" then . else empty end
' | grep -v "^Caveat:" \
| grep -v "^<command" \
| grep -v "^<local-command" \
| grep -v "^This session is being continued" \
| grep -v "^<user-prompt-submit-hook>" \
| grep -v "^Analysis:" \
| grep -v "^$"
```
### Step 4: Create/Update .chats Files
Create markdown files in `.chats/` directory with format:
```markdown
# Instructions
## {task title}
{user instruction}
## {another task title}
{another user instruction}
```
### Step 5: Commit Changes
After creating/updating chat files, commit with:
```bash
git add .chats/*.md
git commit -m "docs(chats): add session history for {date range}"
```
## File Format
Each `.chats/{YYYYMMDD}.md` file should:
- Start with `# Instructions` header
- Use `##` for each major task/instruction
- Include the actual user input text
- Group related instructions under the same heading
- Preserve code blocks and formatting
## Example Output
`.chats/20251225.md`:
```markdown
# Instructions
## implement feature X
based on @specs/feature-x.md implement all phases entirely
commit the code and test
## fix bug Y
investigate why component Z is not working
use sub agents to analyze the issue in parallel
```
## Filtering Rules
**Include:**
- Direct user instructions and requests
- Questions about the codebase
- Task specifications and requirements
**Exclude:**
- System commands (`<command-name>`, `<local-command-stdout>`)
- Session continuation messages
- Tool results and agent responses
- Hook notifications (`<user-prompt-submit-hook>`)
- Empty lines and caveat messages
## Workflow Summary
1. Get current working directory
2. Compute encoded project path
3. Find session directory: `~/.claude/projects/{encoded-path}/`
4. List sessions grouped by date
5. For each date with sessions:
- Extract user inputs from all sessions
- Create `.chats/{YYYYMMDD}.md`
- Organize inputs with descriptive headers
6. Create `.chats/` directory if it doesn't exist
7. Optionally commit the changes
## Helper Script
You can use this bash snippet to quickly find the project session directory:
```bash
# Get encoded project path
PROJECT_PATH=$(pwd | sed 's|/|-|g' | sed 's|^|/|' | sed 's|^/|-|')
SESSION_DIR="$HOME/.claude/projects/$PROJECT_PATH"
# Check if exists
if [ -d "$SESSION_DIR" ]; then
echo "Session directory: $SESSION_DIR"
echo "Sessions by date:"
ls -la "$SESSION_DIR"/*.jsonl 2>/dev/null | grep -v agent- | awk '{print $6, $7}' | sort -u
else
echo "No session directory found for this project"
fi
```
## Notes
- Session files named `agent-*.jsonl` are sub-agent sessions and typically don't contain direct user input
- Main session files have UUID-style names (e.g., `01e78099-de0e-4424-845c-518638c8241e.jsonl`)
- The `.message.content` field can be either a string (user text) or an array (tool results)
- Always verify the extracted content makes sense before committing
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.