Teaching AI Agents to Time-Travel: Building a Temporal Debugging Skill A developer built temporal-debug-skill, a portable skill definition that teaches AI coding agents to debug production bugs by analyzing historical code snapshots using git worktree instead of the current HEAD. The skill auto-activates when temporal context is detected, guiding agents to resolve the correct commit, create an isolated worktree, analyze the historical code, and clean up. It addresses a common failure where agents waste time debugging code that didn't exist when the crash occurred. Your AI agent is confident. It points to line 42 of PaymentService.java . "There's your null pointer exception." You check. Line 42 is a comment. The code was refactored 14 commits ago. The production crash happened 3 hours ago . Your agent just spent 45 minutes debugging ghosts . Every AI coding agent today — Claude Code, Cursor, Copilot, Cody, you name it — operates on the same assumption: The code that matters is at HEAD . But production bugs don't live at HEAD . They live in the commit that was running when the crash happened. That commit is buried under hotfixes, refactors, dependency updates, and feature merges that landed after the incident. HEAD now ← Agent analyzes THIS │ ├─ feat: add new payment provider ├─ refactor: extract UserService ├─ fix: handle edge case in checkout ├─ chore: update dependencies │ ▼ a1b2c3d 3 hours ago ← Bug ACTUALLY lives HERE Your agent confidently finds bugs in code that didn't exist when the crash occurred . We don't need a time machine. Git has had one for years: git worktree . Get the commit from 3 hours ago git log --before="3 hours ago" -1 --format="%H" → a1b2c3d4e5f6... Create an isolated, read-only snapshot at that commit git worktree add /tmp/debug-a1b2c3d a1b2c3d Now analyze the historical codebase cat /tmp/debug-a1b2c3d/src/PaymentService.java Clean up when done git worktree remove --force /tmp/debug-a1b2c3d This gives you: Agents already know git log , git show , git diff , cat , grep . They can analyze code perfectly. What they struggle with : So I built temporal-debug-skill — a portable skill definition that teaches any agent to handle exactly those two gaps. Think of it as a prompt template with superpowers . It's a Markdown file that tells an agent: "When you detect X context, here are the exact git commands to run, in this order, with this cleanup guarantee." No Python. No Node. No installation. Just instructions the agent follows . skills/temporal-debug/SKILL.md simplified Activation Trigger when user message contains temporal anchors: - "3 hours ago", "last night", "yesterday" - "v2.4.1", "tag:release-42" - "the deploy before...", "commit before..." Workflow 1. RESOLVE: git log --before="