TeamGitHub repo hooks

GitHub Repo Hooks

Deploy AgentKeeper hooks via your Git repository. Commit a .claude/settings.json once, every developer who clones the repo gets automatic Claude Code policy enforcement for that repository.

Deploy AgentKeeper hooks via your Git repository. Commit a .claude/settings.json once, every developer who clones the repo gets automatic Claude Code policy enforcement for that repository.

This is the repository-scoped team deployment method. For individual setup, see Claude Code Setup. For managed endpoint deployment, start with Enterprise install, then choose Windows, macOS, or Linux RPM.

How it works

Claude Code loads hooks from .claude/settings.json in the repository root. When a developer clones and opens the repo in Claude Code, the hooks activate automatically. No per-machine configuration is required for Claude Code policy events.

Repo hooks are intentionally narrow: they do not install the desktop gateway, do not scan local IDE configuration, and do not run scan-inventory. Use the Jamf, Iru/Kandji, Intune, Linux Universal RPM, or gateway install path when you also need workstation posture, Cowork plugin inventory, MCP server inventory, or skills/plugin visibility.

For MCP runtime coverage, keep the tool matchers set to *. MCP calls appear as tool names like mcp__notion__notion-create-pages, so a narrow built-in matcher misses them.

Repo hooks also carry repository context through Claude Code. When Allowed Git Remotes is configured in AgentKeeper policy, Runtime Shield blocks startup and tool use in repositories that do not match the approved remote patterns.

Step 1: Get your API key

  1. Log in to www.agentkeeper.dev
  2. Go to Settings → Access → API keys and create a key
  3. Copy the key (starts with ak_live_)

Step 2: Add hooks to your repo

Create .claude/settings.json in your repository root:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "http",
            "url": "https://www.agentkeeper.dev/api/v1/claude-code/evaluate",
            "headers": { "Authorization": "Bearer YOUR_API_KEY" },
            "timeout": 10
          }
        ]
      }
    ],
    "PreToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "http",
            "url": "https://www.agentkeeper.dev/api/v1/claude-code/evaluate",
            "headers": { "Authorization": "Bearer YOUR_API_KEY" },
            "timeout": 10
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "http",
            "url": "https://www.agentkeeper.dev/api/v1/claude-code/audit",
            "headers": { "Authorization": "Bearer YOUR_API_KEY" },
            "timeout": 10
          }
        ]
      }
    ],
    "SessionStart": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "http",
            "url": "https://www.agentkeeper.dev/api/v1/claude-code/checkin",
            "headers": { "Authorization": "Bearer YOUR_API_KEY" },
            "timeout": 10
          }
        ]
      }
    ]
  }
}

Replace YOUR_API_KEY with your key from Step 1.

Step 3: Commit and push

git add .claude/settings.json
git commit -m "Add AgentKeeper policy hooks"
git push

Every developer who pulls this commit gets AgentKeeper monitoring on their next Claude Code session.

Automated via GitHub App

Instead of manually committing the file, you can use the AgentKeeper GitHub integration to automatically push hooks into connected repositories via pull request.

Repository allowlists

Use Policies -> Git remotes or Settings -> Security Policies -> Git Repository Restrictions to restrict Claude Code activity to approved repositories:

github.com/your-org/*
git@github.com:your-org/production-infra.git
github.com/your-org/security-*

AgentKeeper normalizes common HTTPS and SSH remote forms before matching. Empty means all remotes are allowed.

For Claude Code, enforcement happens at runtime:

HookBehavior
SessionStartBlocks the session when the reported git remote is outside the allowlist
PreToolUseBlocks tool calls if the session or workstation resolves to a non-allowed remote

The GitHub App can distribute hooks into selected repositories and track which repos are protected. It does not replace GitHub permissions, branch protection, or CODEOWNERS.

Security notes

  • The API key is write-only. It can send events and check policies, but cannot read org data.
  • Hook calls use Claude Code's native HTTP hook payloads with a 10-second timeout. If www.agentkeeper.dev is unreachable, Claude Code continues normally.
  • Native Claude Code payloads may include user prompts, command strings, file paths, edit/write tool inputs, and post-tool outputs. AgentKeeper receives those payloads over HTTPS and stores bounded, redacted event context for policy evaluation and audit. Use the gateway install path if you need local redaction before upload.
  • Project-level hooks in .claude/settings.json merge with user-level hooks in ~/.claude/settings.json.