Mario Alexandre  ·  March 26, 2026  ·  open-source auto-scatter claude-code

How to Install the Auto-Scatter Hook for Claude Code

This is the install guide. Want the story and numbers first? Read my how I saved $1,588 article. Ready to install? Keep reading.

Total time: about 15 minutes. You need Python 3.9+, Claude Code, and an Anthropic API key.

sinc-LLM — what gets injected on every prompt
x(t) = Σ x(nT) · sinc((t - nT) / T)
Step 1 of 5
Get the code

Leave a comment on any sinc-LLM article and I will send you the GitHub link. The repo is github.com/mdalexandre/sinc-llm. Clone it or download the ZIP.

git clone https://github.com/mdalexandre/sinc-llm
cd sinc-llm
Step 2 of 5
Install dependencies and start the server

The scatter server is a FastAPI app. Install the requirements. Then start the server. It runs on port 8461.

pip install -r requirements.txt

# Start the scatter server (keep this running)
uvicorn sinc_llm.scatter_server:app --port 8461 --host 127.0.0.1

# Or run as background process on Windows:
# start /b py -X utf8 -m uvicorn sinc_llm.scatter_server:app --port 8461

Check that it is running. Open http://127.0.0.1:8461/health in your browser. It should return {"status": "ok"}.

Step 3 of 5
Set your Anthropic API key

The scatter server calls Claude Haiku. Set your API key as an environment variable:

# Windows
set ANTHROPIC_API_KEY=sk-ant-your-key-here

# Or add to your .env file in the sinc-llm directory
ANTHROPIC_API_KEY=sk-ant-your-key-here
Step 4 of 5
Register the hook in Claude Code

Find your Claude Code settings.json. On Mac or Linux it is usually at ~/.claude/settings.json. On Windows it is at %APPDATA%\Claude\settings.json. Add the hook entry:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": ".*",
        "hooks": [{
          "type": "command",
          "command": "py -X utf8 /path/to/sinc-llm/sinc_llm/scatter_hook.py"
        }]
      }
    ]
  }
}

Replace /path/to/sinc-llm with the real path where you installed sinc-llm. On Windows, use forward slashes or double backslashes.

Step 5 of 5
Verify it's working

Restart Claude Code. Send any prompt. You should see the scatter JSON before the response. The hook echoes the output so you can confirm it is running.

# Run the test script to confirm hook is active
py -X utf8 sinc_llm/test_scatter.py

# Expected output:
# [PASS] Server health check
# [PASS] Scatter API response
# [PASS] sinc JSON validation (6 bands present)
# [PASS] Pass-through detection (sinc JSON input)
# [PASS] Edge case: @agent routing
# All tests passed.

Troubleshooting

Hook not firing: Check the settings.json path and its JSON syntax. Claude Code will not load a broken settings file without warning. Check the logs at ~/.claude/logs/.

Scatter server not reachable: Make sure uvicorn is running and port 8461 is open. If the server is down, the hook switches to heuristic scatter. You will see "[FALLBACK]" in the output.

Haiku API errors: Check that ANTHROPIC_API_KEY is set in the environment where uvicorn runs. Setting it only in the install terminal is not enough.

Windows path issues: Always use py -X utf8. Do not use python or python3 on Windows. Use forward slashes in the hook command path.

// Production AI Engineering

Build AI systems that hold up in production.

sinc-LLM designs, audits, and stabilises production AI infrastructure: from vendor evaluation and cost accountability to incident controls and MCP architecture.

See what we do →