AGENT SKILL

pre-compact-backup

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.

License 许可
Apache-2.0
最近更新
2026-11-13
Stars
★ 13
Forks
2

01 前言 Front Matter

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.

03 SKILL.md 正文

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

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:

{
  "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.

04 同仓库更多 Skills

Horonomos-laps
Horonomos-laps/Yana-AI

openai--sentry--sentry

Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ito-basket-compare

Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-network-traffic-baselining

Build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

detecting-evasion-techniques-in-endpoint-logs

Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

implementing-microsegmentation-with-guardicore

Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.

★ 13
Horonomos-laps
Horonomos-laps/Yana-AI

ramdisk-tmpfs-patterns

暂无简介

★ 13