add-git-sync

add-git-sync is a skill for Claude Code from Abilityai/abilities. It costs 43 tokens per session (3,422 once invoked), scanned B, original, MIT.

A set of Git hooks that uses an agent's own Git repository to save and restore its working state across sessions.

In plain words
What is it for?
Use it to rebase when a session starts, save work before context is shortened, and commit and push changes when the agent stops. It is intended for standalone repositories, not repositories inside a larger monorepo, which is one repository containing multiple projects.
Why use it?
It reduces the risk of losing unfinished work or having different sessions start from inconsistent repository contents.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions subagents.

Part of the agent-dev plugin — 47 skills shipped together

Good fit Use it to rebase when a session starts, save work before context is shortened, and commit and push changes when the agent stops. It is intended for standalone repositories, not repositories inside a larger monorepo, which is one repository containing multiple projects.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/abilityai/abilities/add-git-sync
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Abilityai/abilities --skill add-git-sync
Clone the repo
git clone --depth 1 https://github.com/Abilityai/abilities

Made for: Claude Code.

Or install agent-dev, the plugin that ships this one along with the rest of its 47 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-git-sync

README.md
[![agentmods](https://agentmods.dev/badge/skills/abilityai/abilities/add-git-sync/github.svg)](https://agentmods.dev/skills/abilityai/abilities/add-git-sync)
Your own site
<a href="https://agentmods.dev/skills/abilityai/abilities/add-git-sync"><img src="https://agentmods.dev/badge/skills/abilityai/abilities/add-git-sync/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for add-git-sync

Your own site · 80×15
<a href="https://agentmods.dev/skills/abilityai/abilities/add-git-sync"><img src="https://agentmods.dev/badge/skills/abilityai/abilities/add-git-sync.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,422 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.03422
Opus 5.5 $0.00017 $0.01369
Sonnet 5.5 $0.00009 $0.00684
Haiku 4.5 $0.00004 $0.00342

Measured 6d ago against content hash 6c8b8fb5630e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

add-git-sync scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (templates/git-pre-compact.sh, templates/git-session-start.sh, templates/git-sync-local.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

- "1.3: .gitignore rationale corrected — the platform no longer bakes ~/.claude/settings.json (guardrail registration moved to root-owned /etc/claude-code/managed-settings.json, ent#345); the ignore rule stays because a
plugins/agent-dev/skills/add-git-sync/SKILL.md · 284 lines

How it starts

The opening of the file, as written. The whole thing — 284 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Add Git Sync

ℹ️ First, set expectations: before anything else, print one short line with this skill's version and its most recent change — the top entry of metadata.changelog above — e.g. add-git-sync vX.Y — recent: <summary>. Then proceed.

Installs three hooks that turn the agent's own repo into its durable state layer:

Hook Event Job
git-session-start.sh SessionStart (startup/resume) Stash local drift → fetch → rebase onto remote branch → restore drift. Every session begins consistent with origin.
git-pre-compact.sh PreCompact Fast local commit so in-flight work survives context compaction. No push.
git-sync.sh Stop (async) git add -A → commit → push with rebase-on-reject retry. Drops .git/SYNC_FAILED if it can't reconcile; SessionStart surfaces the note next run.

Who this is for: any agent whose directory is its own git repo and benefits from cross-session continuity (Trinity-deployed agents, autonomous workers, long-running research agents). Not appropriate for agents nested inside a larger monorepo.

Why this pairs with deployment: Trinity deploys an agent by cloning its GitHub repo and tracking the branch, so the remote agent's state is whatever the branch tip holds. These hooks keep that tip honest — work is committed and pushed at session end instead of lingering uncommitted, so a git_pull (or /trinity:sync) actually carries the agent forward. Install this before deploying, not after the first surprise.

Escape hatches baked in:

  • touch .git/NO_AUTOSYNC — disables all three hooks
  • echo "..." > .git/SELF_SELECT_MSG — subagents write structured commit messages that survive the generic Stop-hook commit
  • .git/SYNC_FAILED — propagates push failures forward to the next session

Process

Step 1: Preflight

Run from inside the target agent directory (or ask the user for the path). Verify:

# 1. CWD has CLAUDE.md (i.e. is an agent root)
[ -f CLAUDE.md ] || ask_user_for_agent_path

# 2. CWD is a git repo root (not nested). Resolve both sides with `pwd -P`
#    so macOS /tmp vs /private/tmp symlinks don't cause a false positive.
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
if [ -z "$REPO_ROOT" ]; then
  # Not a git repo — ask whether to init
  :
elif [ "$(cd "$REPO_ROOT" && pwd -P)" != "$(pwd -P)" ]; then
  # Nested inside a larger repo — refuse or offer local-only
  echo "ERROR: Agent dir is nested inside $REPO_ROOT. Hooks would push the wrong scope."
  exit 1
fi

# 3. Does .claude/settings.json exist? (create if missing)
# 4. Do any of the target hooks already exist? (if yes, diff and ask)

Read the full file on GitHub · 284 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago Changed · +1 lines 6c8b8fb5630e
  2. 1mo ago Changed · +3 lines 3d6e627307a5
  3. 1mo ago First seen · 280 lines · 43 tokens per session scan B 4ef2c4992841

Subscribe to this mod's changes

add-git-sync is a skill published in the GitHub repository Abilityai/abilities (12 stars, last pushed 3d ago), licensed MIT. It adds 43 tokens to every session and 3,422 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.