# slicing-code-context

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.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1300 installs · ★ 7805
- Author: trailofbits
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills/tree/HEAD/plugins/trailmark/skills/slicing-code-context/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/slicing-code-context

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill slicing-code-context -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/slicing-code-context/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/slicing-code-context/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill slicing-code-context -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/slicing-code-context/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill slicing-code-context -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/slicing-code-context/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install trailofbits/skills slicing-code-context
```

2. **Manually: put the files in place**
- File: `.github/skills/slicing-code-context/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill slicing-code-context -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/trailofbits/skills --path plugins/trailmark/skills/slicing-code-context
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/slicing-code-context/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill slicing-code-context -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/trailofbits/skills/tree/HEAD/plugins/trailmark/skills/slicing-code-context/SKILL.md

## When to use it
- 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
- 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

## Similar
- [analyze-project](https://affpapa.org/en/nevibecode/skills/analyze-project.md) — skill · 337200 installs
- [github-research](https://affpapa.org/en/nevibecode/skills/github-research.md) — skill · 1800 installs
- [spec-miner](https://affpapa.org/en/nevibecode/skills/spec-miner.md) — skill · 4400 installs
- [codex](https://affpapa.org/en/nevibecode/skills/codex.md) — skill · 4100 installs
- [gemini](https://affpapa.org/en/nevibecode/skills/giuseppe-trisciuoglio-gemini.md) — skill · 3400 installs
- [rust-symbol-analyzer](https://affpapa.org/en/nevibecode/skills/rust-symbol-analyzer.md) — skill · 3100 installs

From the same set: [trailofbits/skills](https://affpapa.org/en/nevibecode/by/trailofbits/skills.md) — 77 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
