slicing-code-context — Claude Code skill: how it works and setup
Extracts bounded, graph-informed source code slices via Trailmark and delegates analysis to a smaller subagent. Useful when running focused tasks on local or constrained models.
npx skills add trailofbits/skills --skill slicing-code-context -a claude-codeWhat slicing-code-context does
This skill coordinates between a primary agent and a constrained worker model. Instead of feeding the entire codebase into a context window, the coordinator uses build_slice_packet.py to extract a deterministic source slice via Trailmark. The resulting packet captures exact graph neighbors around a target symbol or line span.
Slicing supports several graph modes: immediate neighborhood, caller chains with upstream, downstream impact with downstream, and end-to-end paths with path or entrypoint. Running the helper script requires Python 3.12+ and uv to manage Trailmark 0.5.x. The default budget sets an estimated packet limit of 8192 tokens.
Workers operate in read-only mode and may only propose patches. If a subagent reports missing context, the coordinator generates a single focused packet expansion, but the worker never browses the repository directly. In-code comments are treated as untrusted data, so every cited line range requires coordinator verification before applying any patch.
What it helps with
- isolate a call graph neighborhood without loading the full repository
- delegate code review tasks to smaller or locally hosted models
- trace execution paths between entry points and specific targets
- verify proposed code patches against exact line-level source slices
Example prompts for the agent
- Build a neighborhood slice for verify_session and send it to the worker agent to review
- Trace downstream calls from process_payment with depth 2 and propose a refactoring diff
- Find the call path between route_handler and write_record to check input sanitization
How to install slicing-code-context
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill slicing-code-context -a claude-code2Manually: put the files in place
~/.claude/skills/slicing-code-context/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/slicing-code-context/
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill slicing-code-context -a codex2Manually: put the files in place
.agents/skills/slicing-code-context/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill slicing-code-context -a cursor2Manually: put the files in place
.cursor/skills/slicing-code-context/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install trailofbits/skills slicing-code-context2Manually: put the files in place
.github/skills/slicing-code-context/SKILL.md1Skills CLI (Vercel)
npx skills add trailofbits/skills --skill slicing-code-context -a gemini-cli2Platform CLI
gemini skills install https://github.com/trailofbits/skills --path plugins/trailmark/skills/slicing-code-contextManually: put the files in place
.devin/skills/slicing-code-context/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add trailofbits/skills --skill slicing-code-context -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about slicing-code-context
How do I install slicing-code-context in Claude Code?
Run npx skills add trailofbits/skills --skill slicing-code-context -a claude-code in your terminal.
What does slicing-code-context do?
It generates deterministic, graph-bounded code slices using Trailmark and hands them to a subagent. The coordinator manages file modifications and verifies all worker outputs.
What are the requirements for the slicing script?
It requires Python 3.12 or newer alongside uv. The script uses Trailmark 0.5.x to parse symbols and calculate graph relations.