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.
The Problem: Agents Are Stuck in the Present
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.
The Insight: Git Already Has Time Travel
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:
- ✅ Isolated — doesn't touch your working directory
- ✅ Parallel — can have multiple historical snapshots simultaneously
- ✅ Disposable — cleanup is one command
- ✅ Zero deps — pure Git, works everywhere
The Missing Piece: Teaching Agents When to Time-Travel
Agents already know git log, git show, git diff, cat, grep. They can analyze code perfectly.
What they struggle with:
- Fuzzy time → commit resolution — "last night", "v2.4.1", "the deploy before the hotfix"
- Worktree lifecycle management — create, track, guarantee cleanup
So I built temporal-debug-skill — a portable skill definition that teaches any agent to handle exactly those two gaps.
What Is an "Agentic Skill"?
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="<time>" -1 --format="%H"` → commit SHA
2. SNAPSHOT: `git worktree add /tmp/temporal-debug-<sha> <sha>`
3. ANALYZE: Read files from worktree, trace the bug
4. CLEANUP: `git worktree remove --force /tmp/temporal-debug-<sha>`
5. REPORT: Root cause + historical commit reference + introducing commit
See It In Action
Scenario 1: Production Crash with Timestamp
You: "Crash from 3 hours ago:
NullPointerException in PaymentService.java:42"Agent (with skill):
git log --before="3 hours ago" -1 --format="%H"→a1b2c3dgit worktree add /tmp/temporal-debug-a1b2c3d a1b2c3d- Reads
PaymentService.java:42from worktree →user.getEmail()without null checkgit worktree remove --force /tmp/temporal-debug-a1b2c3d- Reports: "In commit
a1b2c3d(3 hrs ago),PaymentService.java:42accessesuser.getEmail()without null check.useris null for guest checkouts. Introduced inf8e9d0a."
Scenario 2: Version-Pinned Bug Report
You: "Users on v2.4.1 report auth failures" (attaches error log)
Agent: Resolves tag
v2.4.1→ worktree → finds regex bug in auth middleware skipping validation for/health-records→ reports fix already in v2.4.2
Scenario 3: Regression Detective
You: "This endpoint 200'd last week, now 500s. Changelog shows nothing."
Agent: Resolves "last week" → creates two worktrees (last week + HEAD) → diffs relevant modules → finds pool size config regression from 50 → 10
Installation: 30 Seconds
For Claude Code (Recommended)
# Clone into your project's skills directory
git clone https://github.com/MeherBhaskar/temporal-debug-skill.git skills/temporal-debug-skill
That's it. The skill auto-activates when temporal context is detected.
For Any Shell-Capable Agent
cp -r temporal-debug-skill/skills/temporal-debug/ /path/to/your/agent/skills/
Why This Approach? (Design Philosophy)
| ✅ Skill Does | ❌ Skill Doesn't |
|---|---|
| Detects temporal context automatically | Require a CLI tool invocation |
| Resolves fuzzy time → exact commits | Need external scripts/binaries |
Creates isolated git worktree snapshots |
Touch your working directory |
| Guarantees cleanup (even on error) | Require Python/Node/Go runtime |
| Works in ANY git repo, ANY language | Analyze code for you (you're better at that) |
The skill is additive. It teaches the agent one new trick (time-travel via worktree). Everything else — reading files, tracing logic, suggesting fixes — the agent already does.
Real-World Impact
Since adding this to my workflow:
| Before | After |
|---|---|
| 45 min debugging wrong version | 30 sec to historical root cause |
"Which commit broke this?" → git bisect manual |
Agent tells you: "Introduced in f8e9d0a" |
| Context-switching to check historical code | Stay in conversation, agent brings history to you |
Roadmap
- [ ] Multi-repo temporal analysis — debug across microservice boundaries
- [ ] CI/CD integration — auto-trigger on failed builds, post temporal context as PR comment
- [ ] Diff analysis mode — side-by-side historical vs. current comparison
- [ ] Automated patch generation — from root cause to fix PR
- [ ] Observability integrations — Sentry, Datadog, PagerDuty webhooks
- [ ] VS Code extension — visual time-travel debugging
Try It
git clone https://github.com/MeherBhaskar/temporal-debug-skill.git
# Drop into your agent's skills directory
Repo: https://github.com/MeherBhaskar/temporal-debug-skill
License: MIT — use it, fork it, ship it.
Discussion
Have you hit the "agent debugging wrong version" problem?
What temporal anchors do you use most — "3 hours ago", version tags, "last deploy"?
Building agent tools?
The skill pattern (Markdown instructions → agent executes shell) is surprisingly powerful for bridging agent capabilities. Happy to discuss the architecture.
Stop debugging ghosts. Start debugging history. ⏪
Top comments (0)