Skip to content

rogvc/turnstile

Repository files navigation

Turnstile

A fast, simple, deterministic Claude Code auto-allow mode, for the masses.

CI Go Reference Go Report Card Release License

Turnstile lets Claude Code run the safe commands you'd never bother to confirm and stops the dangerous ones before they reach the model. It's a PreToolUse hook that returns allow, ask, or deny from a TOML ruleset in a couple of milliseconds.

Claude Code's built-in permissions block uses exact string matching and operates after the tool call reaches the harness. Turnstile runs at the PreToolUse hook stage with RE2 regular expressions, gives deny precedence over allow, supports scoped cd roots so directory traversal is blocked, and parses Bash commands segment-by-segment so pipelines, subshells, and redirections are validated independently. That makes it easy to express policies like "allow all git commands except those that modify remote state" or "block kubectl delete anywhere in a pipeline."

Quickstart

Install the binary:

go install github.com/rogvc/turnstile@latest

Wire it up:

turnstile install

Or manually merge this into ~/.claude/settings.json (assuming turnstile is on your PATH):

{
  "hooks": {
    "PreToolUse": [
      {
        "hooks": [{ "type": "command", "command": "turnstile", "timeout": 1 }]
      }
    ]
  }
}

Verify it's working:

turnstile --test 'git status'
# Expected: allow

turnstile --test 'sudo rm -rf /'
# Expected: deny

Documentation

For everything else, see the docs directory:

  • Usage covers managing rules, testing decisions, and the exit code contract.
  • Configuration covers the config file format, recipes, environment-variable assignments, and path-qualified commands.
  • How it works covers the hook protocol, decision reasons, performance, and the security model.
  • Claude Skill covers installing the /turnstile skill so Claude can manage rules from conversation.

Contributing

PRs welcome. Please run make ci before submitting and ensure tests pass. For bugs, feature requests, or questions, open an issue in the GitHub tracker.

License

MIT

About

A fast, simple, deterministic Claude Code auto-allow mode.

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors