Back up conversation transcript before context compaction. Use when: PreCompact hook fires, user asks to save session state, or before long tasks where context loss would be costly. Creates timestamped backup in logs/transcript_backups/. Inspired by: disler/claude-code-hooks-mastery pre_compact pattern.
Scanned 9/9/2026
Install to Claude Code
npx -y skills add yanacuti1121/Yana-AI --skill pre-compact-backup --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Pre Compact Backup?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/yanacuti1121-pre-compact-backup)More formats (shields.io, HTML) on the badges page.
---
name: "pre-compact-backup"
description: "Back up conversation transcript before context compaction. Use when: PreCompact hook fires, user asks to save session state, or before long tasks where context loss would be costly. Creates timestamped backup in logs/transcript_backups/. Inspired by: disler/claude-code-hooks-mastery pre_compact pattern."
---
# Pre-Compact Backup Skill
## When to trigger
- PreCompact hook fires (automatic)
- "save session before compact", "lưu transcript"
- "backup context", "sao lưu phiên làm việc"
- Before starting a very long multi-step task
## What to do
### Step 1 — Identify transcript location
Check for `.claude/state/` or default Claude Code transcript paths.
### Step 2 — Create backup
```bash
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="logs/transcript_backups"
mkdir -p "$BACKUP_DIR"
# Copy current transcript if accessible
cp .claude/transcript.jsonl "$BACKUP_DIR/transcript_${TIMESTAMP}.jsonl" 2>/dev/null || true
```
### Step 3 — Tag the backup
Write a short metadata file alongside:
```json
{
"timestamp": "YYYY-MM-DDThh:mm:ssZ",
"trigger": "manual | pre-compact-hook",
"branch": "[current-branch]",
"last_commit": "[sha]"
}
```
### Step 4 — Report
```
Backup saved: logs/transcript_backups/transcript_[timestamp].jsonl
Trigger: [manual | pre-compact-hook]
Branch: [branch]
```
## Graceful degradation
- If transcript not accessible: log the attempt, do not error
- If logs/ does not exist: create it
- Never block compaction — backup is best-effort
- Silent failure is acceptable; noisy failure is not
## Notes
This skill is informational — the actual backup is best done via a PreCompact hook wired in `settings.json`. This skill documents the pattern and can be invoked manually when needed.
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!