Make a local codebase searchable from Claude Code or OpenClaw with semantic code search, filtered long outputs, and exact-replacement file edits.
The SWE Lite verification reports include token and turn breakdowns for Claude
Code and OpenClaw runs. We chose text-embedding-3-large as the embedding
model.
| Claude Code | OpenClaw |
|---|---|
![]() |
![]() |
| Metric | Legacy | ContextSniper | ContextSniper Filter | ContextSniper Reduction | ContextSniper Filter Reduction |
|---|---|---|---|---|---|
| Input tokens | 1,534,963 | 941,761 | 810,396 | -39% | -47% |
| Output tokens | 16,969 | 11,656 | 11,946 | -31% | -30% |
| Total tokens | 1,551,933 | 953,417 | 822,342 | -39% | -47% |
| Metric | Legacy | ContextSniper | ContextSniper Filter | ContextSniper Reduction | ContextSniper Filter Reduction |
|---|---|---|---|---|---|
| Input tokens | 1,309,937 | 769,590 | 622,321 | -41% | -52% |
| Output tokens | 17,439 | 10,399 | 12,982 | -40% | -26% |
| Total tokens | 1,327,377 | 779,989 | 635,303 | -41% | -52% |
ContextSniper ships two local plugins:
| Host | Plugin | What it adds |
|---|---|---|
| Claude Code | claude-plugin/ | MCP tools for code search/edit plus prompt policy injection |
| OpenClaw | openclaw-plugin/ | Native tools, prompt policy injection, and read/exec filtering |
Both plugins can start the local ContextSniper backend and AGFS service for you, then stop the services they started when the host exits.
Prepare a fresh checkout once:
git clone https://github.com/Calluking/ContextSniper.git
cd ContextSniper
./bootstrap.shbootstrap.sh is interactive for setup steps: if Ubuntu packages or Python
.venv are missing, it asks before installing anything. It also checks whether
OpenClaw and Claude Code are installed, then asks which integration to set up.
It does not ask you to type API keys into the installer.
Export your model and embedding settings: (Use deepseek and text-embedding-3-small as example)
export DEEPSEEK_API_KEY="<your-deepseek-key>"
export DEEPSEEK_BASE_URL="https://api.deepseek.com"
export OPENCLAW_MODEL="deepseek/deepseek-v4-flash"
export CONTEXTSNIPER_EMBEDDING_API_KEY="<your-embedding-key>"
export CONTEXTSNIPER_EMBEDDING_BASE_URL="https://api.openai-proxy.org"
export CONTEXTSNIPER_EMBEDDING_MODEL="text-embedding-3-small"
export ANTHROPIC_MODEL="haiku"Then load the settings:
source setup_env.sh./bootstrap.sh creates .venv, installs the runtime dependencies in
requirements.txt, and builds agfs/build/agfs-server. Full SWE-bench
validation is optional; install that heavier stack only when needed with
./bootstrap.sh --install-swe-deps.
From the project you want Claude to edit:
cd /path/to/project
claude --plugin-dir "$CONTEXTSNIPER_DIR/claude-plugin"Do not pass --mcp-config; the Claude plugin owns its .mcp.json.
From the project you want OpenClaw to edit:
cd /path/to/project
openclaw chat --local- Python 3.11+
- Go 1.22+
- Claude Code CLI, OpenClaw CLI, or both
- An OpenAI-compatible embedding endpoint and API key
- Conda, only if you use the SWE runner's default local validation environment
Claude:
/plugin
Expected status:
contextsniper Plugin · inline · ✔ enabled
└ contextsniper MCP · ✔ connected
OpenClaw:
openclaw plugins inspect contextsniper --runtime --jsonThe runtime output should include:
contextsniper_health
contextsniper_index_codebase
contextsniper_search_code
contextsniper_edit_file
To confirm a run used ContextSniper search/filtering:
latest=$(ls -t ~/.openclaw/agents/*/sessions/*.jsonl | grep -v trajectory | head -1)
rg -n "ContextSniper|FILTER IS TRIGGERED|contextsniper_search_code|contextsniper_edit_file" "$latest"For Claude, inspect the current Claude debug log or the /plugin panel. A
healthy code run should show MCP tool names containing search_code and
edit_file.
Local settings should come from your shell environment or shell profile, which
setup_env.sh imports before applying repo defaults. Do not commit real API
keys.
Common settings:
| Variable | Purpose |
|---|---|
CONTEXTSNIPER_EMBEDDING_API_KEY |
API key for real semantic code search |
CONTEXTSNIPER_EMBEDDING_BASE_URL |
OpenAI-compatible embedding endpoint |
CONTEXTSNIPER_EMBEDDING_MODEL |
Embedding model name |
PY_BIN |
Optional Python override for plugin/backend runtime |
CONTEXTSNIPER_FILTER_ENABLED |
Toggle read/exec filtering, default 1 |
CONTEXTSNIPER_INJECT_FILTERING_PROMPT |
Toggle the filtering-strategy prompt section |
requirements.txt includes httpx[socks], and setup_env.sh sets
NO_PROXY/no_proxy for 127.0.0.1, localhost, and ::1 so local ContextSniper/AGFS
traffic bypasses HTTP(S)/SOCKS proxies.
- bootstrap.sh: one-command local setup.
- setup_env.sh: shared environment loader.
- claude-plugin/prompts/code_policy_injection.txt: Claude policy prompt.
- openclaw-plugin/prompts/code_policy_injection.txt: OpenClaw policy prompt.
- docs/assets/readme/: generated README diagrams. Refresh with
python3 docs/assets/readme/generate_readme_diagrams.py. - scripts/SWE/: SWE Lite runners and reports.
- LICENSE: Mulan Permissive Software License v2 (
MulanPSL-2.0).
The SWE runners build a task prompt and start Claude or OpenClaw non-interactively. See scripts/SWE/README.md for the six runner modes, run commands, output locations, and log checks.
This project is licensed under the Mulan Permissive Software License v2
(MulanPSL-2.0). See LICENSE.





