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

How to Install the Auto-Scatter Hook for Claude Code

This is the step-by-step install guide. If you want the backstory and numbers first, read my how I saved $1,588 article. If you're here to install, let's go.

Total time: about 15 minutes. Prerequisites: Python 3.9+, Claude Code installed, 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'll 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 and start it in the background. 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

Verify it's running: open http://127.0.0.1:8461/health in your browser. 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 (usually at ~/.claude/settings.json on Mac/Linux or %APPDATA%\Claude\settings.json on Windows). 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 your actual install path. 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 displayed before the response — the hook is configured to echo the structured output so you can confirm it's 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 settings.json path and JSON syntax. Claude Code won't load a malformed settings file silently — check logs at ~/.claude/logs/.

Scatter server not reachable: Confirm uvicorn is running and port 8461 is not blocked. The hook falls back to heuristic scatter if the server is unreachable — you'll see "[FALLBACK]" in the hook output.

Haiku API errors: Check ANTHROPIC_API_KEY is set in the environment where uvicorn runs, not just the terminal where you installed.

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

Try sinc-LLM free — sincllm.com

Leave a comment for the GitHub link if you need it.