backup-before-troubleshooting
This skill is the discipline behind a recoverable, self-documenting troubleshooting effort. It
is also the single source of truth for the safety and scripting rules: the plugin's
commands (new-recovery-effort, recovery-status, cleanup) defer to the rules here rather
than restating them, so there is one place to read and one place to change.
The rules below are not style preferences. Each one is here because its absence caused real
damage during the multi-day desktop-app recovery this generalizes. Where a rule has a "why",
read it — understanding the failure it prevents is what lets you apply it to a new situation
instead of following it blindly.
When to use
Use this when both are true:
- You are about to mutate state — config, application data, system files, installed
components, extensions/plugins — as part of troubleshooting, and
- You want to be able to undo the changes and forensically reconstruct what
happened later (which change caused what, including a fix that introduced a new problem).
Also use it when resuming an effort that already has a recovery workspace.
When not to use
- Read-only diagnosis, quick questions, or trivially reversible edits.
- Code work already under version control — git already gives you reversibility and history.
- Backing up a single directory of plain-text config: a quick
git init there is lighter than
a full effort. Reach for this skill when the change spans system/app state, when you need the
forensic narrative, or when "undo" means more than git checkout.
Platform assumptions
macOS-first (Time Machine, ~/Library/Application Support, rsync -aE, iCloud). The
discipline is portable; the exact commands are not. Two cross-platform hazards are called out
where they bite (xattr flags, iCloud placeholders). Before adapting to Linux, read
references/platform-notes.md.
Core model: the recovery effort
The unit of organization is the recovery effort — one named goal that may span hours or
days and accumulate many backups and diagnostic artifacts. One effort is one folder. It is
not one folder per file, per command, or per step; individual artifacts and their
timestamps are rows in a manifest, never their own folders. (Folder-per-artifact was tried
and produced an unnavigable sprawl that defeated reconstruction.)
"Recovery effort" is prose only. The phrase never appears in a path.
Workspace layout
${RECOVERY_ROOT:-~/Recovery}/ # root: the program directory
README.md # program directory — program-folder -> human identity
{Program}/
README.md # effort index — one row per effort (+ program version)
YYYY-MM-DD_HHMMSS_<goal-kebab>/ # one recovery effort; timestamp = when the effort began
README.md # what this effort is; the incident; the layout
CHANGELOG.md # what was done and when, newest first (the running detail log)
DECISIONS.md # ADR-style: each hypothesis, the conclusion, and what was RULED OUT
RESTORE.md # the restore runbook for this effort's backups
CURRENT-STATE.md # what is true on disk right now; overwritten each run
MANIFEST.md # one table: artifact -> original absolute path -> purpose -> confidence
files/ # backups — two populations (see below)
evidence/ # diagnostic record — PROTECTED, never a deletion target
RECOVERY_ROOT defaults to ~/Recovery and is configurable (see config.example.env). It
must be a location that is always materialized locally — never ~/Downloads or ~/Desktop,
which are iCloud-evictable. The three README levels and the per-effort docs (including how the
program's own version is recorded at three granularities) are specified in
references/workspace-layout.md. Read it before seeding a new
effort by hand; the new-recovery-effort command seeds them for you.
The forensic core: files/ and evidence/
These are siblings, and they are treated differently by cleanup. Keeping them separate is
deliberate: it is what lets cleanup delete backups without ever endangering the evidence.
files/ holds backups, in two populations:
- Copied in — artifacts duplicated into
files/ at their mirrored absolute path
(a backup of /Users/x/Library/.../config.json lands at
files/Users/x/Library/.../config.json). This makes the workspace self-documenting and
restore near-symmetric. Mechanic: references/path-preservation.md.
- Referenced in place — large folders that are not copied. They are renamed with a
backup marker at their original location (e.g.
Claude.bak, claude-ext-disabled) and
recorded in MANIFEST.md. This avoids two real failures: hitting PATH_MAX when deep
session caches are re-nested under files/, and duplicating gigabytes of app data.
evidence/ holds the diagnostic record: hang/crash logs, boot logs, command output,
screenshots, and any log excerpts pasted during the effort. It is protected — never a
deletion target (see safety principle 6).
Safety principles (single source of truth)
Discover real paths before referencing them. Never write a command against a constructed
or assumed path. List or stat it, confirm it exists, then act on the confirmed path. Why:
an assumed path silently backs up nothing, or worse, names the wrong target for a later
destructive step.
Copy, don't move, by default. Leave originals in place and produce duplicates. Delete an
original only in a separate, explicit, post-verification cleanup step. Why: a move is a
backup and a deletion in one irreversible motion; if the copy is bad you have destroyed the
only good copy.
Restore safely, in order: dry-run first (rsync -n), move the live target aside (rename
it with a timestamp), then restore, then re-verify the state. Why: a restore that
overwrites in place can destroy the current (possibly fixed) state if the backup turns out
to be wrong. Full runbook: references/restore-runbook.md.
Document confidence. When an artifact's purpose or origin is uncertain, say so plainly in
MANIFEST.md: HIGH / MEDIUM / LOW plus a one-line note. Why: honest uncertainty lets a
future reader (or a cleanup decision) weigh the artifact correctly; false precision gets
things deleted that should have been kept.
Surface recurring gotchas loudly. If something keeps undoing an action — a restore that
silently reverts a pinned setting, a sync that re-evicts a file — put a warning at the top
of CURRENT-STATE.md. Why: the next person (often you, days later) will otherwise rediscover
the trap the hard way.
Docs and evidence are never deletion targets. In every effort and every cleanup tier, the
protected set is: every *.md at all three README levels, the six per-effort docs, and the
entire evidence/ folder. Cleanup only ever targets files/ contents and the
manifest-listed external in-place folders. Why: the record of what happened must outlive the
backups it describes.
Scripting rules
- No
set -e in discovery / inventory scripts. Optional ls/probe commands on missing
paths return non-zero, and with set -e in an interactive shell that kills the user's
terminal tab. Guard probes with 2>/dev/null and let the script run to the end.
- Copy-paste command blocks contain no inline comments. A block handed to the user must be
clean, top-to-bottom executable. Explanation goes in the surrounding prose, never inside the
block.
- Paths:
~/ in docs, absolute in commands. Write ~/Library/... for readability in docs,
but expand to the real absolute path in any command — never create a literal ~ directory.
- Paths must be byte-accurate, including capitals and spaces (e.g.
Claude Extensions).
- The internal recovery docs omit any "Generated:" footer. They are a working record, not a
published artifact.
Workflows
- Start an effort — create the dated folder and seed the docs, then back up before each
mutation. Use the
new-recovery-effort command, or follow
references/workflows.md to do it by hand.
- Back up an artifact — discover and confirm the real path (principle 1), then file it.
Filing is a guided, discovery-first copy-paste block, intentionally not a turnkey script
— see references/workflows.md and
references/path-preservation.md.
- Resume — read
CURRENT-STATE.md, the open items in DECISIONS.md, and any gotcha
warnings, then brief the user on where the effort left off. Use the recovery-status command.
- Restore — follow references/restore-runbook.md. Restore
is a deliberate, read-each-step runbook, never a one-shot command.
- Clean up — use the
cleanup command. It is gated and deliberate (user-invocation only),
and it enforces the protected set in principle 6.
- Already-scattered artifacts (two-pass migration) — pass 1 discovers and reports real
paths and moves nothing; pass 2 files them from the confirmed inventory. Never file from an
assumed path. See references/workflows.md.
References
- references/workspace-layout.md — directory scheme, the three
README levels, the six effort docs, and the program-version model.
- references/path-preservation.md — the
rsync --relative
mechanic and the -aE (macOS) vs -X (GNU) cross-platform flag difference.
- references/workflows.md — starting, filing, and the two-pass
migration, as comment-free copy-paste blocks.
- references/restore-runbook.md — the safe-restore procedure.
- references/platform-notes.md — macOS assumptions, the iCloud
source-materialization caveat, and Linux adaptation notes.
1---2name: backup-before-troubleshooting3description: Stand up a dated, self-documenting recovery workspace BEFORE changing system, app, or configuration state, so every change is reversible and the whole effort can be forensically reconstructed afterward — including regressions caused by your own fixes. Use this whenever you are about to mutate config, application data, system files, or installed components during troubleshooting AND want to be able to both undo the changes and reconstruct what happened later. Trigger phrases: "back this up first", "before I start messing with this", "I want to be able to undo this", "set up a recovery folder", "track this troubleshooting", or when resuming an effort that already has a recovery workspace. Do NOT use for read-only diagnosis, trivially reversible edits, or code work already tracked by git.4---56# backup-before-troubleshooting78This skill is the discipline behind a recoverable, self-documenting troubleshooting effort. It9is also the **single source of truth** for the safety and scripting rules: the plugin's10commands (`new-recovery-effort`, `recovery-status`, `cleanup`) defer to the rules here rather11than restating them, so there is one place to read and one place to change.1213The rules below are not style preferences. Each one is here because its absence caused real14damage during the multi-day desktop-app recovery this generalizes. Where a rule has a "why",15read it — understanding the failure it prevents is what lets you apply it to a new situation16instead of following it blindly.1718## When to use1920Use this when **both** are true:21221. You are about to **mutate** state — config, application data, system files, installed23 components, extensions/plugins — as part of troubleshooting, and242. You want to be able to **undo** the changes **and** **forensically reconstruct** what25 happened later (which change caused what, including a fix that introduced a new problem).2627Also use it when **resuming** an effort that already has a recovery workspace.2829## When not to use3031- Read-only diagnosis, quick questions, or trivially reversible edits.32- Code work already under version control — git already gives you reversibility and history.33- Backing up a single directory of plain-text config: a quick `git init` there is lighter than34 a full effort. Reach for this skill when the change spans system/app state, when you need the35 forensic narrative, or when "undo" means more than `git checkout`.3637## Platform assumptions3839macOS-first (Time Machine, `~/Library/Application Support`, `rsync -aE`, iCloud). The40discipline is portable; the exact commands are not. Two cross-platform hazards are called out41where they bite (xattr flags, iCloud placeholders). Before adapting to Linux, read42[references/platform-notes.md](references/platform-notes.md).4344## Core model: the recovery effort4546The unit of organization is the **recovery effort** — one named goal that may span hours or47days and accumulate many backups and diagnostic artifacts. One effort is one folder. It is48**not** one folder per file, per command, or per step; individual artifacts and their49timestamps are **rows in a manifest**, never their own folders. (Folder-per-artifact was tried50and produced an unnavigable sprawl that defeated reconstruction.)5152"Recovery effort" is prose only. The phrase never appears in a path.5354## Workspace layout5556```57${RECOVERY_ROOT:-~/Recovery}/ # root: the program directory58 README.md # program directory — program-folder -> human identity59 {Program}/60 README.md # effort index — one row per effort (+ program version)61 YYYY-MM-DD_HHMMSS_<goal-kebab>/ # one recovery effort; timestamp = when the effort began62 README.md # what this effort is; the incident; the layout63 CHANGELOG.md # what was done and when, newest first (the running detail log)64 DECISIONS.md # ADR-style: each hypothesis, the conclusion, and what was RULED OUT65 RESTORE.md # the restore runbook for this effort's backups66 CURRENT-STATE.md # what is true on disk right now; overwritten each run67 MANIFEST.md # one table: artifact -> original absolute path -> purpose -> confidence68 files/ # backups — two populations (see below)69 evidence/ # diagnostic record — PROTECTED, never a deletion target70```7172`RECOVERY_ROOT` defaults to `~/Recovery` and is configurable (see `config.example.env`). It73must be a location that is always materialized locally — never `~/Downloads` or `~/Desktop`,74which are iCloud-evictable. The three README levels and the per-effort docs (including how the75program's own version is recorded at three granularities) are specified in76[references/workspace-layout.md](references/workspace-layout.md). Read it before seeding a new77effort by hand; the `new-recovery-effort` command seeds them for you.7879## The forensic core: `files/` and `evidence/`8081These are **siblings**, and they are treated differently by cleanup. Keeping them separate is82deliberate: it is what lets cleanup delete backups without ever endangering the evidence.8384- **`files/`** holds backups, in two populations:85 1. **Copied in** — artifacts duplicated into `files/` at their *mirrored absolute path*86 (a backup of `/Users/x/Library/.../config.json` lands at87 `files/Users/x/Library/.../config.json`). This makes the workspace self-documenting and88 restore near-symmetric. Mechanic: [references/path-preservation.md](references/path-preservation.md).89 2. **Referenced in place** — large folders that are *not* copied. They are renamed with a90 backup marker at their original location (e.g. `Claude.bak`, `claude-ext-disabled`) and91 recorded in `MANIFEST.md`. This avoids two real failures: hitting `PATH_MAX` when deep92 session caches are re-nested under `files/`, and duplicating gigabytes of app data.9394- **`evidence/`** holds the diagnostic record: hang/crash logs, boot logs, command output,95 screenshots, and any log excerpts pasted during the effort. It is **protected** — never a96 deletion target (see safety principle 6).9798## Safety principles (single source of truth)991001. **Discover real paths before referencing them.** Never write a command against a constructed101 or assumed path. List or stat it, confirm it exists, then act on the confirmed path. *Why:*102 an assumed path silently backs up nothing, or worse, names the wrong target for a later103 destructive step.1041052. **Copy, don't move, by default.** Leave originals in place and produce duplicates. Delete an106 original only in a separate, explicit, post-verification cleanup step. *Why:* a move is a107 backup and a deletion in one irreversible motion; if the copy is bad you have destroyed the108 only good copy.1091103. **Restore safely, in order:** dry-run first (`rsync -n`), move the live target aside (rename111 it with a timestamp), then restore, then re-verify the state. *Why:* a restore that112 overwrites in place can destroy the current (possibly fixed) state if the backup turns out113 to be wrong. Full runbook: [references/restore-runbook.md](references/restore-runbook.md).1141154. **Document confidence.** When an artifact's purpose or origin is uncertain, say so plainly in116 `MANIFEST.md`: HIGH / MEDIUM / LOW plus a one-line note. *Why:* honest uncertainty lets a117 future reader (or a cleanup decision) weigh the artifact correctly; false precision gets118 things deleted that should have been kept.1191205. **Surface recurring gotchas loudly.** If something keeps undoing an action — a restore that121 silently reverts a pinned setting, a sync that re-evicts a file — put a warning at the **top**122 of `CURRENT-STATE.md`. *Why:* the next person (often you, days later) will otherwise rediscover123 the trap the hard way.1241256. **Docs and evidence are never deletion targets.** In every effort and every cleanup tier, the126 protected set is: every `*.md` at all three README levels, the six per-effort docs, and the127 entire `evidence/` folder. Cleanup only ever targets `files/` contents and the128 manifest-listed external in-place folders. *Why:* the record of what happened must outlive the129 backups it describes.130131## Scripting rules132133- **No `set -e` in discovery / inventory scripts.** Optional `ls`/probe commands on missing134 paths return non-zero, and with `set -e` in an interactive shell that **kills the user's135 terminal tab**. Guard probes with `2>/dev/null` and let the script run to the end.136- **Copy-paste command blocks contain no inline comments.** A block handed to the user must be137 clean, top-to-bottom executable. Explanation goes in the surrounding prose, never inside the138 block.139- **Paths: `~/` in docs, absolute in commands.** Write `~/Library/...` for readability in docs,140 but expand to the real absolute path in any command — never create a literal `~` directory.141- **Paths must be byte-accurate**, including capitals and spaces (e.g. `Claude Extensions`).142- **The internal recovery docs omit any "Generated:" footer.** They are a working record, not a143 published artifact.144145## Workflows146147- **Start an effort** — create the dated folder and seed the docs, then back up before each148 mutation. Use the `new-recovery-effort` command, or follow149 [references/workflows.md](references/workflows.md) to do it by hand.150- **Back up an artifact** — discover and confirm the real path (principle 1), then file it.151 Filing is a guided, discovery-first copy-paste block, intentionally **not** a turnkey script152 — see [references/workflows.md](references/workflows.md) and153 [references/path-preservation.md](references/path-preservation.md).154- **Resume** — read `CURRENT-STATE.md`, the open items in `DECISIONS.md`, and any gotcha155 warnings, then brief the user on where the effort left off. Use the `recovery-status` command.156- **Restore** — follow [references/restore-runbook.md](references/restore-runbook.md). Restore157 is a deliberate, read-each-step runbook, never a one-shot command.158- **Clean up** — use the `cleanup` command. It is gated and deliberate (user-invocation only),159 and it enforces the protected set in principle 6.160- **Already-scattered artifacts (two-pass migration)** — pass 1 discovers and reports real161 paths and moves nothing; pass 2 files them from the confirmed inventory. Never file from an162 assumed path. See [references/workflows.md](references/workflows.md).163164## References165166- [references/workspace-layout.md](references/workspace-layout.md) — directory scheme, the three167 README levels, the six effort docs, and the program-version model.168- [references/path-preservation.md](references/path-preservation.md) — the `rsync --relative`169 mechanic and the `-aE` (macOS) vs `-X` (GNU) cross-platform flag difference.170- [references/workflows.md](references/workflows.md) — starting, filing, and the two-pass171 migration, as comment-free copy-paste blocks.172- [references/restore-runbook.md](references/restore-runbook.md) — the safe-restore procedure.173- [references/platform-notes.md](references/platform-notes.md) — macOS assumptions, the iCloud174 source-materialization caveat, and Linux adaptation notes.