Skip to content

About

Back up, sync and restore Codex, Claude Code and DeepSeek Harness conversations with one private Git repo. One folder per device, no server.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

git-agent-history

Back up, sync and restore your Codex / Claude Code / DeepSeek Harness conversations with one private Git repository.

简体中文

Coding agents keep their history only on the machine they ran on. A new laptop, a rebuilt container, or the agent's own cleanup wipes it out: Claude Code, for example, keeps transcripts for only 30 days by default. git-agent-history runs in the background, backs them up to a private GitHub repository you own, and restores them on any machine.

  • Just a private Git repo. No server and no account.
  • One folder per device. Devices never conflict, and only new content is uploaded.
  • Native files. Restored sessions can be resumed directly, and old project paths can be mapped to new ones.
  • Safe defaults. It refuses public repos, redacts common credentials before committing, and never overwrites existing files when restoring.

🤖 Let your agent set it up (recommended)

On the machine you want to back up, paste this into Codex, Claude Code or DeepSeek Harness:

Set up https://github.com/mzhangzhicheng/git-agent-history on this machine so that my agent conversations are backed up automatically to my private GitHub repository YOUR_NAME/agent-history (create it if missing). Follow docs/agent-setup.md in that repository and enable autostart. If GitHub login is needed, let me finish it in the browser; never ask for or print tokens.

Do this once on each machine. You can also install it as a skill with npx skills add mzhangzhicheng/git-agent-history.

Manual setup

Requires Python 3.9+, git and the GitHub CLI.

gh auth login --web && gh auth setup-git
pipx install git+https://github.com/mzhangzhicheng/git-agent-history

git-agent-history init --repo YOUR_NAME/agent-history --create   # register this machine
git-agent-history once        # back up now
git-agent-history autostart   # run in the background and on login; syncs every 5 minutes
git-agent-history status

Cloud containers. First export GIT_AGENT_HISTORY_HOME=/persistent/disk/.git-agent-history. Then add the command printed by git-agent-history startup-command to the platform's start-up script. After every rebuild, it refills this machine's history from the backup and keeps syncing.

Restore

git-agent-history pull && git-agent-history devices          # list devices
git-agent-history export  --from-device DEVICE --agent codex --target ./inspect   # look first
git-agent-history restore --from-device DEVICE --agent claude-code --target ~/.claude \
  --map-cwd /Users/me/code=/home/me/code                     # if project paths changed
  • Existing files are never overwritten. Add --session ID to restore a single conversation.
  • After restoring into a running agent's home, restart the agent.

Read every prompt you typed

After each backup, every machine rewrites a readable list of the prompts typed on it, by month, in devices/<device-id>/prompts/README.md of the history repository. Open it on GitHub. To search across all machines:

git-agent-history pull && git-agent-history prompts --grep "login" --markdown

See docs/prompts.md for what counts as a prompt and the search options.

Hand off tasks between agents

Agents on different machines can pass work to each other through the same private repository. For example, Claude Code on your laptop can hand a task to Codex in a cloud container. Each task has a spec (goal, acceptance criteria, roles, context) and a log, and it records whose turn it is.

git-agent-history handoff new --title "Add login API" --from claude-code --to codex --file spec.md
git-agent-history handoff list --for codex                  # on the other machine
git-agent-history handoff show TASK --markdown
git-agent-history handoff post TASK --from codex --to claude-code --status review -m "Tests added on branch login"

Writes are pushed right away. See docs/handoff.md for the model and for instructions to give your agents.

Supported agents

Agent What is backed up
Codex sessions, session index and a state_*.sqlite snapshot from ~/.codex
Claude Code sessions (including subagents) from ~/.claude/projects, and history.jsonl
DeepSeek Harness session logs from ~/.dsh/sessions

Credentials, settings, plugins, attachments and project code are not backed up.

Security

  • Every upload first checks that the repository is private.
  • Common credentials (OpenAI, Anthropic, GitHub, AWS and other tokens, private keys) are replaced with [REDACTED] before committing. This is a safety net; keep the repo private.
  • The repository is not encrypted. Anyone with access to it can read the conversations.

Related projects

This project backs up every agent session on every machine and lets agents on different machines hand work to each other. It needs nothing but a private Git repository.

See docs/design.md for details.

License

MIT © 2026 Zhicheng Zhang. Codex, Claude Code and DeepSeek Harness belong to OpenAI, Anthropic and DeepSeek respectively. This project is independent and not affiliated with them.

About

Back up, sync and restore Codex, Claude Code and DeepSeek Harness conversations with one private Git repo. One folder per device, no server.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages