context-safe-patch-handling
Never echo a Jules patch body into the orchestrator's context — always route through `tools/jules-patch-extract.py` which writes the patch to…
Skill by netzkontrast
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/netzkontrast-context-safe-patch-handling
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: research, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/context-safe-patch-handling
What's inside
- Skill name
context-safe-patch-handling- Description
- Never echo a Jules patch body into the orchestrator's context — always route through `tools/jules-patch-extract.py` which writes the patch to `/tmp/jules-patches/` and emits only stats. Use when the user or context mentions "large patch", "Jules patch", "patch > 2 KB", "extract patch", "/tmp/jules-patches/", or "context-safe", or whenever you are about to read, grep, or apply a patch produced by a remote coding agent.
- License
- MIT
- Instructions
- 143 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
## The rule (one sentence)
`cat`, `head`, `grep`, and `Read` are FORBIDDEN against any file under
`/tmp/jules-patches/` or any patch artefact larger than ~2 KB — route
through `tools/jules-patch-extract.py` and consume only its JSON stats.
## Why this exists
Jules patches routinely span tens to hundreds of KB. Pulling one into
the orchestrator's context window — even via a one-line `head` — burns
thousands of tokens on diff content the LLM does not need to reason
about. The orchestrator's job is to decide *whether* to apply, not to
re-derive the diff. On 2026-05-17, a single `cat` of a 47 KB patch cost
~12 K tokens and degraded subsequent decisions for the rest of the
session.
The extractor solves this once: it writes the patch to disk, reads
filenames by line-scanning (no diff content ever enters Python
memory), and emits a compact JSON summary. The body stays on disk
where `git apply` can reach it without the LLM ever seeing it.
## The extractor — real CLI surface
Source: `tools/jules-patch-extract.py`. Read its docstring (lines 1–26)
for the contract.
### Required env
| Variable | Purpose |
|---|---|
| `JULES_API_KEY` | Required for all invocations. Used in `X-Goog-Api-Key` header against `https://jules.googleapis.com/v1alpha/sessions/{sid}`. |
| `AGENCY_REPO_ROOT` | Optional. Overrides repo-root auto-detection when `--apply` is used. |
### Positional + flags
```
python3 tools/jules-patch-extract.py <session_id> [--apply] [--branch NAME] [--repo PATH]
```
| Token | Meaning |
|---|---|
| `<session_id>` | The Jules session ID (positional, required). |
| `--apply` | After saving the patch to disk, run `git apply --stat` then `git apply --whitespace=nowarn` against the resolved repo. Without `--apply` the script only saves + emits stats. |
| `--branch NAME` | (Only with `--apply`.) Before applying, runs `git checkout Master`, `git pull origin Master`, `git checkout -B NAME`. Fails fast on any base-prep error — never swallowed. |
| `--repo PATH` | Override repo root. Priority order: `--repo` > `$AGENCY_REPO_ROOT` > `git rev-parse --show-toplevel`. |
### Output shape (JSON to stdout)
```json
{
"sid": "<session_id>",
"patches": [
{
"path": "/tmp/jules-patches/<sid>-out0.patch",
"bytes": 12345,
"files": 7,
"first_files": ["path/a.py", "path/b.md", "..."],
"has_more": false,
"apply": { // only when --apply is used
"stat_stdout": "...", // filenames + +/- counts ONLY
"stat_stderr_lines": 0,
"apply_returncode": 0,
"apply_stderr_preview": "" // capped at 2 KB
}
}
],
"skipped_after_failure": { // present only if apply failed mid-batch
"count": 2,
"note": "Subsequent patches were not applied because an earlier patch failed; resolve the failure and re-run."
}
}
```
Exit codes:
- `0` — success (or no `--apply`).
- `1` — usage error, repo-root unresolved, base-branch prep failed, or
`git apply` failed.
- `2` — session has no `outputs[].gitPatch.unidiffPatch` to extract.
## Usage patterns
### Stats-only inspection (decide whether to apply)
```bash
python3 tools/jules-patch-extract.py <sid>
```
Returns the JSON above without touching the working tree. Use this
before deciding whether the patch is worth applying — file count and
first 12 filenames are enough for that judgment.
### Apply to a fresh branch off Master
```bash
AGENCY_REPO_ROOT=$(pwd) python3 tools/jules-patch-extract.py <sid> \
--apply --branch claude/<spec-slug>-recovered-<sid-short>
```
Branches off the current `origin/Master`, applies the patch, leaves
uncommitted changes ready for `git commit`.
### Apply in-place on the current branch
```bash
AGENCY_REPO_ROOT=$(pwd) python3 tools/jules-patch-extract.py <sid> --apply
```
No branch prep — applies to wherever HEAD currently points. Use only
when you have already prepared the branch by hand.
## What NOT to do
| Forbidden | Why |
|---|---|
| `cat /tmp/jules-patches/<sid>-out0.patch` | Pulls the entire diff into context. Use the extractor's `first_files` instead. |
| `head -n 200 <patch>` | Still pulls hundreds of diff lines — same problem at smaller scale. |
| `grep <pattern> <patch>` | Even matched lines bring surrounding hunk headers and file paths into context. If you need to know whether a file is touched, check `first_files[]` (capped at 12) or run the extractor without `--apply` and inspect the JSON. |
| `Read` tool against a patch file | Same as `cat`. The `Read` tool returns content into context. |
| Echoing `git diff` output for an applied patch into context | Apply, then commit. Do not read the diff back — `git apply --stat` already printed the structural summary you need. |From netzkontrast/agency, MIT.
More from netzkontrast/agency
- 0.479score
loop-library
netzkontrast
Discover, find, compare, audit, repair, adapt, and design repeatable AI-agent loops with explicit triggers, actions, verification, stopping conditions…
SkillCFreshness: CClaude Code +9 - 0.474score
silent-fail-recovery
netzkontrast
Deterministic recovery for Jules sessions that reach COMPLETED state without producing a remote branch (the "silent-fail" bug).
SkillCFreshness: CClaude Code +9 - 0.474score
jules-orchestrator-discipline
netzkontrast
Six hard-won orchestrator rules for dispatching, watching, and harvesting Google Jules sessions — derived from the 2026-05-17 silent-fail incidents.
SkillCFreshness: CClaude Code +9 - 0.474score
ponytail
netzkontrast
Use when building or reviewing agency's frugal discipline (Spec 332) or multi-agent self-installer (Spec 333), or when you want the minimal-code "lazy senior…
SkillCFreshness: CClaude Code +9 - 0.471score
orchestrate
netzkontrast
Run a Jules session through its full lifecycle — dispatch, plan approval, monitor, verify, integrate — driven by the jules-row state machine.
SkillCFreshness: CClaude Code +9 - 0.471score
jules-orchestrator
netzkontrast
Delegates long-running codebase tasks (refactors, multi-file edits, test generation, feature implementation, automated PR creation) to the Google Jules…
SkillCFreshness: CClaude Code +9 - 0.469score
research
netzkontrast
Research a topic and return findings as a tool-result envelope.
SkillCFreshness: CClaude Code +9 - 0.469score
recover
netzkontrast
Recover a silent-failed Jules session — extract its patch metadata into the ontology and (optionally) apply it locally.
SkillCFreshness: CClaude Code +9 - 0.467score
music-clipboard
netzkontrast
Copies track content (lyrics, style prompts, streaming lyrics) to the system clipboard.
SkillCFreshness: CClaude Code +9 - 0.467score
music-document-hunter
netzkontrast
Searches and retrieves documents from free public sources using automated browser navigation.
SkillCFreshness: CClaude Code +9 - 0.467score
music-cloud-uploader
netzkontrast
Uploads promo videos and content to Cloudflare R2 or AWS S3.
SkillCFreshness: CClaude Code +9 - 0.467score
music-album-conceptualizer
netzkontrast
Designs album concepts, tracklist architecture, and thematic planning through 7 structured phases.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jun 8, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/netzkontrast/agency
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from netzkontrast
- 0.479score
loop-library
netzkontrast
Discover, find, compare, audit, repair, adapt, and design repeatable AI-agent loops with explicit triggers, actions, verification, stopping conditions…
SkillCFreshness: CClaude Code +9 - 0.474score
jules-orchestrator-discipline
netzkontrast
Six hard-won orchestrator rules for dispatching, watching, and harvesting Google Jules sessions — derived from the 2026-05-17 silent-fail incidents.
SkillCFreshness: CClaude Code +9 - 0.474score
silent-fail-recovery
netzkontrast
Deterministic recovery for Jules sessions that reach COMPLETED state without producing a remote branch (the "silent-fail" bug).
SkillCFreshness: CClaude Code +9 - 0.474score
ponytail
netzkontrast
Use when building or reviewing agency's frugal discipline (Spec 332) or multi-agent self-installer (Spec 333), or when you want the minimal-code "lazy senior…
SkillCFreshness: CClaude Code +9 - 0.471score
orchestrate
netzkontrast
Run a Jules session through its full lifecycle — dispatch, plan approval, monitor, verify, integrate — driven by the jules-row state machine.
SkillCFreshness: CClaude Code +9 - 0.471score
jules-orchestrator
netzkontrast
Delegates long-running codebase tasks (refactors, multi-file edits, test generation, feature implementation, automated PR creation) to the Google Jules…
SkillCFreshness: CClaude Code +9
Cite this page
context-safe-patch-handling skill. Agent Mart. https://agentmart.dev/skills/netzkontrast-context-safe-patch-handling (last updated 2026-10-24)