Which Recovery Layer Should You Check First When AI Skills Vanish Without Git?
Stop writing large files to disk immediately, check Trash and editor Local History first if you edited inside an IDE, and check APFS local snapshots first if a terminal coding agent overwrote global folders. Personal skill directories such as ~/.codex/skills, ~/.claude/skills, ~/.gemini/antigravity/skills, and gitignored .cursor/rules/*.mdc overrides rarely enter Git, so recovery depends on catching ephemeral editor or OS snapshots before they rotate out.
Avoid package installs, builds, or cache purges until missing skill files are copied to a safe recovery folder. Heavy writes pressure purgeable APFS snapshot space, while extra saves in Cursor or Antigravity push older revisions past the 50-entry Local History eviction ceiling. Match your lost surface to its primary recovery layer:
| Lost AI Skill / Rule Surface | Typical Failure Mode | Check First | Retention Window |
|---|---|---|---|
| Cursor (.cursor/rules/*.mdc, AGENTS.md) | Saved overwrite in Cursor IDE or agent edit inside open workspace | IDE Local History Timeline + User/History/<hash>/entries.json | Up to 50 saved entries per file (<= 256 KB each) |
| Google Antigravity (.agents/rules/*.md, ~/.gemini/antigravity/skills/) | Modified in Antigravity IDE or overwritten by subagent write_file | Antigravity User/History/<hash>/entries.json, then APFS snapshot | 50 editor entries per file; 24h hourly APFS local snapshots |
| OpenAI Codex CLI (~/.codex/skills/, AGENTS.override.md) | Shell rm, script truncation, or terminal agent rewrite outside an IDE | macOS APFS Time Machine local snapshot (tmutil + mount_apfs -s) | Hourly local snapshots kept 24 hours on startup APFS volume |
| Claude Code (~/.claude/skills/<name>/SKILL.md) | Deleted global skill folder or overwritten SKILL.md without Git | macOS Trash (~/.Trash), APFS local snapshot, or Prompttly cloud history | Until Trash emptied; 24h APFS local snapshots; continuous in Prompttly |
| ChatGPT / Claude web custom instructions | Replaced two-box preamble or deleted Custom GPT prompt text in browser | Prompttly version history, browser form cache, or local scratch notes | Browser prompts have zero native Git or filesystem history |
For commits orphaned inside a detached Git worktree rather than untracked folders, run git fsck --lost-found using our Git worktree detached HEAD recovery guide. Otherwise, work down these four non-Git layers in order:
| Recovery Layer | Time to Restore | What It Catches | Blind Spot |
|---|---|---|---|
| 1. Trash & Cloud Sync Revision History | < 30 seconds | Finder deletions, iCloud/Dropbox deleted files, Prompttly library edits | In-place shell overwrites (> foo.md) and rm -rf commands |
| 2. IDE Local History (Cursor / Antigravity / VS Code) | 1–3 minutes | Files saved inside an Electron editor even with zero Git repo | Edits written externally by Codex CLI, Claude Code, or bash scripts |
| 3. macOS APFS Local Snapshots (tmutil + mount_apfs) | 3–8 minutes | rm -rf, terminal agent overwrites, and ~/.claude or ~/.codex deletions | Changes created and deleted between hourly snapshots, or purged when disk <10% free |
| 4. External Backup / Linux Btrfs / Windows Shadow Copy | 5–15 minutes | Files older than 24 hours on Time Machine drives, snapshots, or VSS volumes | Machines with backups disabled or unconfigured snapshot schedules |
The Sprawl Moment: When a Coding Agent Overwrites Uncommitted Global Skills
A staff engineer spends three months iterating on 18 personal workflows—incident triage checklists, SQL migration validators, and framework review rubrics—stored directly in ~/.codex/skills and gitignored .cursor/rules/local-review.mdc files so they do not clutter team repositories. None of those home-directory folders sit inside a Git repo. On a Tuesday afternoon, the engineer asks a terminal agent to “clean up duplicate instructions and consolidate my migration rules,” and the agent runs a shell script that overwrites four carefully tuned SKILL.md packages with stripped-down stubs and deletes a helper script directory. Checking git status returns nothing because those folders were never versioned, leaving hours of hard-won prompt constraints gone right before a production release window.
How Do You Recover Overwritten Cursor, Antigravity, and VS Code Rules Using IDE Local History?
Cursor, Google Antigravity IDE, and Visual Studio Code maintain an independent, per-save file history on disk even when no Git repository exists. Introduced in Visual Studio Code v1.66, Local History stores up to 50 entries per file (workbench.localHistory.maxFileEntries) for files up to 256 KB (workbench.localHistory.maxFileSize), merging consecutive saves only within a 10-second window (workbench.localHistory.mergeWindow).
As documented in the Visual Studio Code v1.66 Local History release notes: “Note: Local history entries are stored in different locations depending on your use of VS Code. When opening local files, the entries are persisted in the local user data folder and when opening remote files, they will be stored on the remote user data folder.”
Method 1: Restore Directly From the Editor Command Palette
- Open Cursor, Google Antigravity IDE, or VS Code in any window and press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Linux/Windows). - Run
Local History: Find Entry to Restore—this searches deleted files too, even if the parent folder like.cursor/rules/was removed. - Type the filename fragment (for example
SKILL.md,AGENTS.md, or.mdc) and pick the timestamp right before the overwrite. - If the file still exists on disk, open it and expand the Timeline pane at the bottom of the File Explorer sidebar to diff and restore any earlier save.
Method 2: Query Raw History Indexes on Disk (When the UI Misses Remote or Renamed Paths)
On macOS, direct inspection of local Electron editor history directories confirms that Cursor, Google Antigravity, and VS Code write hashed subdirectories inside ~/Library/Application Support/<Editor>/User/History/<hash>/. Each directory holds raw file snapshots alongside an entries.json manifest containing version, the original resource URI (file:///...), and an entries array mapping each snapshot's short id to its Unix millisecond timestamp.
Querying entries.json across all Electron editor history folders recovers deleted SKILL.md, AGENTS.md, and .mdc snapshots even when the workspace folder itself was renamed or moved. Run this read-only Python lookup to locate every saved revision of a lost skill or rule across Cursor, Antigravity, and VS Code:
python3 - <<'PY'
import glob, json, os, datetime
needle = "SKILL.md" # change to ".mdc", "AGENTS.md", or a skill folder name
roots = [
os.path.expanduser("~/Library/Application Support/Cursor/User/History"),
os.path.expanduser("~/Library/Application Support/Antigravity/User/History"),
os.path.expanduser("~/Library/Application Support/Code/User/History"),
os.path.expanduser("~/Library/Application Support/Windsurf/User/History"),
os.path.expanduser("~/.config/Code/User/History"),
os.path.expanduser("~/.config/Cursor/User/History"),
]
for root in roots:
for manifest in glob.glob(os.path.join(root, "*", "entries.json")):
with open(manifest, encoding="utf-8", errors="ignore") as f:
data = json.load(f)
resource = data.get("resource", "")
if needle.lower() in resource.lower():
folder = os.path.dirname(manifest)
print(f"\nMATCH: {resource}\nDIR: {folder}")
for item in data.get("entries", [])[-5:]:
ts = datetime.datetime.fromtimestamp(item["timestamp"] / 1000)
print(f" - {ts.isoformat(timespec='seconds')} file={os.path.join(folder, item['id'])}")
PYHow Do You Restore Deleted ~/.codex/skills and ~/.claude/skills via macOS APFS Local Snapshots?
On macOS APFS startup volumes with Time Machine enabled, hourly local snapshots preserve deleted ~/.codex/skills, ~/.claude/skills, and ~/.gemini/antigravity/skills files on your internal SSD for 24 hours—even when no external backup drive is connected. Mounting a local snapshot read-only with mount_apfs -s lets you copy exact pre-deletion skill folders back without rolling back the rest of your system.
According to Apple Support's Time Machine local snapshots documentation: “Time Machine saves one snapshot of your startup disk approximately every hour, and keeps it for 24 hours. It keeps an additional snapshot of your last successful Time Machine backup until space is needed.”
- List all surviving local snapshots on your Mac: Run
tmutil listlocalsnapshots /in Terminal. Each line uses the formatcom.apple.TimeMachine.YYYY-MM-DD-HHMMSS.local. - Create a temporary mount directory and mount the target snapshot read-only: Choose the timestamp immediately before your skill disappeared and pass its full snapshot name to
mount_apfs -s. - Diff and copy only the missing skill or rule files: Copy recovered
SKILL.mdpackages, helper scripts, or.cursor/rules/*.mdcfiles back into your home or project directory, then unmount cleanly.
# 1. List available APFS local snapshots on the startup volume
tmutil listlocalsnapshots /
# Example output:
# com.apple.TimeMachine.2026-12-04-021409.local
# 2. Create a temporary mount point and mount the snapshot read-only
mkdir -p /tmp/apfs-skill-recovery
sudo mount_apfs -o rdonly -s com.apple.TimeMachine.2026-12-04-021409.local / /tmp/apfs-skill-recovery
# 3. Inspect and restore ~/.codex/skills, ~/.claude/skills, or ~/.gemini/antigravity/skills
ls -la "/tmp/apfs-skill-recovery/Users/$USER/.codex/skills"
cp -Rn "/tmp/apfs-skill-recovery/Users/$USER/.codex/skills/." "$HOME/.codex/skills/"
cp -Rn "/tmp/apfs-skill-recovery/Users/$USER/.claude/skills/." "$HOME/.claude/skills/"
# 4. Unmount the snapshot when finished
sudo umount /tmp/apfs-skill-recovery && rmdir /tmp/apfs-skill-recoveryOn macOS Ventura and later, grant Terminal Full Disk Access (System Settings → Privacy & Security) before reading mounted snapshot user folders; on Apple Silicon Macs, substitute /System/Volumes/Data if user home directories mount there. Once restored, configure ongoing backups via our skill backup and cross-computer sync guide.
Why Terminal Coding Agents Silently Bypass IDE Local History During Overwrites
Terminal coding agents such as OpenAI Codex CLI, Claude Code, and Gemini CLI write files directly through POSIX syscalls rather than through an editor's save buffer, so Cursor and VS Code Local History never capture those changes. Understanding that blind spot explains why an engineer can open a repository in Cursor and still find zero Timeline entries for an overwritten AGENTS.md or ~/.codex/skills file.
Three runtime behaviors make non-Git skill loss disproportionately common in multi-agent setups:
- CLI writes bypass editor hooks: OpenAI Codex CLI reads
~/.codex/skillsandAGENTS.mdup to its 32 KiB (32,768-byte) defaultproject_doc_max_bytesbudget documented in the OpenAI Codex AGENTS.md guide, while Claude Code loads~/.claude/skills/<name>/SKILL.mddirectly from disk per the Claude Code Skills documentation. When either CLI edits a file, Electron'sUser/History/watcher is never invoked. - Atomic rewrites break inode recovery: Many agents and editors overwrite files by writing a temp file and calling
rename(2), which replaces the directory entry with a new inode. Even if you usermrecovery tools, the old file's blocks are quickly reclaimed on SSDs with TRIM enabled. - Cross-OS equivalents when you are not on macOS: On Linux workstations without Time Machine, check
~/.local/share/Trash/files/first, then Btrfs or ZFS snapshots (such assnapper listorzfs list -t snapshot) if configured on/home. On Windows or WSL2, right-click the parent folder in File Explorer → Properties → Previous Versions (backed by Volume Shadow Copy / File History), or inspect%APPDATA%\Cursor\User\Historyfor IDE saves.
If your missing instructions happened because edits diverged across two laptops rather than an outright deletion, reconcile them with our multi-laptop prompt drift 3-way merge workflow.
How Do You Prevent Non-Git Skill Deletion Across Machines and Agents?
Prevent permanent skill loss by moving personal skills and prompts out of unversioned local folders into a cloud-backed skill manager that keeps automatic version history and syncs native folders to every machine. Relying on hourly APFS snapshots or 50-entry IDE caches is an emergency rescue net, not a durable workflow when you edit prompts across multiple laptops and agents.
Prompttly is a skill manager for AI agents — one library for your skills and prompts that syncs into Claude Code, Codex, ChatGPT, and Claude and is one hotkey away on your Mac, so your setup follows you across every machine, repo, and tool.
Prompttly maintains automatic version history across every surface and runs two-way sync on Mac back to native ~/.claude/skills and ~/.codex/skills folders, so an accidental agent overwrite or deleted laptop never destroys an uncommitted skill. Instead of remembering to run git commit inside three hidden dotfile directories every evening:
- Automatic Version History on Every Surface: Roll back any edited skill or custom instruction from the web app, Mac menu bar app, or browser extension without managing Git repos around
~/.claudeor~/.codex. - Two-Way Sync Into Native Skill Folders: Prompttly syncs real skill folders into Claude Code and OpenAI Codex CLI (see our Codex CLI skills setup guide), keeping personal workflows separate from team repos.
- Sub-200ms Mac Hotkey Palette & Write-Access MCP: Search and insert prompts into Cursor, Ghostty, or ChatGPT in under 200ms, or connect any AI agent via write-access MCP so updated skills persist automatically.
When is a dedicated skill manager unnecessary? If all your rules live inside one Git-tracked team repository, you push after every edit, and you never keep personal skills in ~/.claude/skills, ~/.codex/skills, or browser instructions, plain Git and nightly backups are enough.
Frequently Asked Questions: Recovering Deleted AI Prompts and Skills
Can you recover a deleted SKILL.md or .cursor/rules/*.mdc file if the folder was never tracked by Git?
Yes. On macOS, check Trash (~/.Trash), then inspect Cursor, Google Antigravity, or VS Code Local History in ~/Library/Application Support/<Editor>/User/History/, and finally mount an hourly APFS Time Machine local snapshot via tmutil listlocalsnapshots / and mount_apfs -s. Even without Git, at least one of those three layers usually retains your previous skill revision for 24 hours or up to 50 editor saves.
Why did Cursor or VS Code Local History miss an overwrite made by OpenAI Codex CLI or Claude Code?
VS Code and Cursor Local History only snapshots a file when the editor writes a save through its own file-system provider. When a terminal coding agent such as OpenAI Codex CLI, Claude Code, or Gemini CLI overwrites ~/.codex/skills or AGENTS.md directly via shell commands or OS write calls, the IDE Local History folder records nothing unless you also saved that file inside the editor.
How long do macOS APFS Time Machine local snapshots keep deleted ~/.claude/skills or ~/.codex/skills folders?
According to Apple Support, Time Machine saves roughly one local snapshot of your startup volume every hour and retains each local snapshot for 24 hours, plus an additional snapshot of your last external Time Machine backup until disk space is needed. Because macOS purges local snapshots automatically when free space runs tight, copy recovered skills out immediately.
How do you stop losing uncommitted AI prompts and skills when switching tools or machines?
Move personal skills and prompts out of fragile untracked folders into a versioned skill manager like Prompttly. Prompttly keeps automatic version history across every edit, syncs native skill folders into ~/.claude/skills and ~/.codex/skills with two-way Mac sync, connects to any agent over MCP, and lets you recall any prompt from a sub-200ms Mac hotkey.
Related Prompt Resources
Never lose another uncommitted AI skill or prompt
Keep your skills and prompts in one versioned Prompttly library with automatic revision history, two-way sync to ~/.claude/skills and ~/.codex/skills, and a sub-200ms Mac hotkey.