Skip to main content
plugin

auto-stage — Claude Code plugin: what it does, how to install

auto-stage stages modified files in Git automatically whenever Claude Code writes or edits them, keeping pre-commit reviews clean without manual git add calls.

MIT ★ 586 updated 2026-10-26

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add karanb192/claude-code-hooks
/plugin install auto-stage@claude-code-hooks
Open on GitHub

What auto-stage does

The plugin registers a synchronous PostToolUse hook attached to Edit and Write actions. Whenever Claude touches a file, the hook resolves its directory and runs git add -- <file> inside the target repository. Your staging area reflects the exact scope of the assistant's work.

Execution relies on execFileSync rather than an open shell, protecting the session from command injection caused by unusual filenames. The tool honors .gitignore: ignored secrets stay out of the index, logging any failed attempts to ~/.claude/hooks-logs/<date>.jsonl. The hook exits with 0 and prints {} so it never interrupts the workflow.

Because the plugin provides zero configuration flags, excluding specific folders inside a tracked repository requires managing them via .gitignore.

What it helps with

  • stage modified files in Git right after tool execution
  • inspect changes Claude made using git status without manual staging
  • prevent untracked edits from being forgotten before committing

Example prompts for the agent

  • Update the authentication logic in src/auth.ts
  • Refactor Button.tsx and create a unit test for it

How to install auto-stage

Plugin marketplace

/plugin marketplace add karanb192/claude-code-hooks
/plugin install auto-stage@claude-code-hooks

Step by step, with commands for each platform: Claude Code plugins: marketplaces, installing, and building your own

Questions about auto-stage

How to install auto-stage in Claude Code?

Run /plugin marketplace add karanb192/claude-code-hooks followed by /plugin install auto-stage@claude-code-hooks in Claude Code, then restart your session.

What does auto-stage do?

It listens for file modifications and runs git add on each updated file to keep the index synced with Claude's edits.

Does auto-stage bypass .gitignore rules?

No, it runs standard staging without force flags, meaning ignored files fail to stage and log an entry instead of entering Git.

Source text

auto-stage · MIT
# auto-stage

> Automatically git stages files after Claude modifies them, so `git status` always shows exactly what Claude touched.

A `PostToolUse` hook fires after every `Edit` and `Write` call, resolves the modified file's path (relative paths are resolved against the session's cwd), checks that it lives inside a git repo, and runs `git add` on it. Review becomes trivial: the staged set IS Claude's change set, and nothing needs manual staging before you commit. The hook stays synchronous on purpose: staging must complete before any later `git commit` in the same turn sees the index.

## Install

```
/plugin marketplace add karanb192/claude-code-hooks   # once per machine
/plugin install auto-stage@claude-code-hooks
```

Restart Claude Code, done. (Or from a shell: `claude plugin install auto-stage@claude-code-hooks`.)

## What it does

| Event | Runs | What happens |
|-------|------|--------------|
| PostToolUse (`Edit\|Write`) | sync | Resolves the file path, skips files outside a git repo, runs `git add -- <file>` in the file's directory, logs the outcome. |

Every outcome (`STAGED`, `SKIP`, `ERROR`) is appended to `~/.claude/hooks-logs/<date>.jsonl`. The hook always exits 0 and prints `{}`; it never blocks the tool call, even on malformed input.

## Configuration

None. The hook has no tunables, no safety levels, and no ask mode. The only environment variable it reads is `HOME`, to place its log under `~/.claude/hooks-logs/`.

## Safety notes

- **.gitignore is your guard.** Ignored files (`.env`, keys, etc.) fail `git add` and the failure is logged; nothing is ever force-added.
- **Shell-free staging.** The path is passed as an argv element via `execFileSync`, so quotes, `$()`, and backticks in a filename cannot break out, and `--` stops a leading dash from being read as a git option.
- **No network calls.** The script only uses `fs`, `path`, and `child_process` (for git), so everything stays on your local machine.

## Uninstall

```
/plugin uninstall auto-stage@claude-code-hooks
```

---

Part of [claude-code-hooks](https://github.com/karanb192/claude-code-hooks).

© Karan Bansal · MIT · karanb192/claude-code-hooks

Similar plugins

All plugins for Git and GitHub →

From the same set28

The whole set →
guard-pack guard-pack is a Claude Code plugin that runs seven guard hooks in one Node process. The first blocking verdict stops the chain. ★ 586repo stars notify-permission notify-permission sends Slack cards when Claude Code waits for permissions or user input, freeing you from watching long-running terminal tasks. ★ 586repo stars session-logger session-logger is a Claude Code plugin that keeps a Markdown record of each session. Its hooks track the repository, touched file paths, and Bash commands. ★ 586repo stars format-code format-code — a PostToolUse hook that formats each file right after Claude writes or edits it: ruff for Python, prettier for JS, TS, JSON, MD, YAML and HTML. ★ 586repo stars config-watch config-watch makes every mid-session change to settings or skills visible in the session, or blocks it outright. Aimed at installers and npm scripts that rewrite config while the agent works. ★ 586repo stars subagent-spawn-cap subagent-spawn-cap counts subagent spawns per session: asks at 20, asks again every 10, refuses at 60. Puts back the cap Claude dropped in 2.1.224. ★ 586repo stars config-guard config-guard — a PreToolUse hook that stops the agent from rewriting the files holding its own guardrails: settings, hook scripts, plugin manifests. Reads pass. ★ 586repo stars case-insensitive-guard case-insensitive-guard is a Claude Code plugin that blocks destructive Bash commands aimed at a path with a different letter case. It checks commands such as rm -rf before they run. ★ 586repo stars

Project sponsors

Companies that keep this analytics open