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
/plugin marketplace add karanb192/claude-code-hooks
/plugin install auto-stage@claude-code-hooksWhat 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 statuswithout 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.tsxand 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-hooksStep 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