Yesterday a small skill file landed on r/PromptEngineering, and it’s the kind of thing that quietly fixes a problem most Claude Code users have stopped noticing because they’re used to it: your agent loading half your repo just to touch two files. You ask for a one-line fix in a service, and three minutes later it’s read the entire monorepo, touched a config file you never mentioned, and you’re left wondering what else changed that you haven’t spotted yet. That’s not a Claude problem specifically. It’s what happens when an agent has no forced checklist between “read the request” and “start editing.”
A developer going by u/Parking-Kangaroo-63 built Context Cartographer, a SKILL.md that acts less like a prompt and more like a checklist your agent has to clear before it’s allowed near your code. It uses Anthropic’s own XML-structure recommendation to wrap the whole thing in tags: contract, scratchpad, workflow steps. The goal: minimum context, maximum signal, zero speculative edits. Instead of letting the model freewheel through your file tree the moment it gets a task, the skill forces a sequence: figure out what’s true, write down what you’re allowed to do, then go looking, in that order, every time.
The twist
Here’s what makes this different from every other “be more efficient” prompt you’ve seen: the scratchpad step. Before the agent writes a single line, it has to sort what it knows into three buckets: User Facts, Repository Evidence, and Inferences. Not two buckets. Three. That third one is the trap most agents fall into: presenting a guess as if it read it in your code. Say you ask for a fix to “the auth middleware,” and the agent has seen a similarly named file in another project’s training data. Without a forced split, that half-memory slides straight into the plan as if it were a fact from your repo. This skill forces the split out loud, so a hallucinated file path can’t hide behind confident phrasing. If the agent can’t cite where in your repo it saw something, it has to label it a guess, and guesses get flagged before they turn into edits.
The mini-workflow
- 📋 Scratchpad first: separate what you said, what the repo actually shows, and what’s just inference. This alone kills most of the “wait, why did it touch that file” moments, because the inference bucket has to be checked against real evidence before anything moves forward.
- 📝 Task contract: objective, scope limits, technical literals, acceptance criteria, all written down before any edit. Think of it as a mini spec the agent writes for itself and then has to honor, so scope creep gets caught at the planning stage instead of showing up as a surprise diff.
- 🔍 Progressive discovery: CLAUDE.md and manifests before deep folder scans, grep before full-file reads. That ordering matters more than it looks. Cheap, targeted lookups first means the agent only pays the cost of a full file read when it’s actually earned that context, instead of ingesting thousands of tokens on files it never needed.
- 🚦 Blocking questions: only when skipping them risks a real architecture change or data loss, otherwise the agent resolves it itself. That’s the part that keeps this from turning into an annoying interrogation before every small task. Trivial ambiguity gets resolved on the agent’s own judgment; only the decisions that are expensive to undo get kicked back to you.
- ✅ Verification loop: real git diff, real tests, no claiming a check passed unless the terminal said so. No “this should work now” without evidence. The agent has to actually run the thing and show you the output, which closes off the laziest failure mode in agentic coding: confident narration standing in for a check that never ran.
Pro tip
Drop this at the top of your CLAUDE.md and watch what happens the next time you ask for a “quick fix” in a monorepo: the agent should stop and ask what’s actually in scope instead of touching six services you never mentioned. One Reddit commenter said Claude Code was loading half their monorepo for a single-service fix before they tried something like this, which is exactly the failure mode this skill targets. Another tip if you manage multiple repos: keep the skill file itself lean and let the task contract step do the heavy lifting per project, since that’s where the actual scope boundaries live, not in the skill definition.
Worth digging into if your agent keeps rewriting files you never asked about. Grab the SKILL.md from the repo and drop it into your own .claude/skills/ folder: github.com/nivlewd1/prompt-optimizer
Frequently Asked Questions
Q: Is Context Cartographer necessary, or should I just iterate with my prompt?
It depends on your project size and agent behavior. For small repos or simple tasks, prompt iteration alone might be enough. But if you’re seeing your agent load unrelated directories, waste tokens, or edit files it shouldn’t touch, a structured framework like Context Cartographer pays for itself quickly. Think of it as a safety layer for larger codebases where prompt drift compounds over time.
Q: Why use XML structure instead of markdown headers for agent prompts?
XML’s explicit opening/closing tags create firmer boundaries in the model’s token stream, it’s harder for adjacent sections to mentally blur together. Markdown headers (especially beyond 3 levels deep) tend to lose structure in long prompts. Users have reported better compliance and fewer “section spillover” mistakes when using XML for nested task boundaries.
Q: Should I ban CLI commands from my agent, or just restrict specific ones?
Go surgical, not blanket. Blanket bans can backfire when your agent legitimately needs a tool for an edge case. Instead, allowlist safe commands and document *why* specific ones are restricted (e.g., “avoid git reset –hard without user confirmation”). This gives the agent flexibility while preventing predictable mistakes.
Q: Won’t the verification loop burn too many tokens?
Yes, but spending tokens on structured pre-flight checks is usually cheaper than letting the agent spiral for 15 minutes, load wrong directories, and create cascading edits. One verification pass upfront beats trial-and-error loops that compound the damage.
Context Cartographer (skill.md) — An XML-Structured Claude Code Skill to Stop Agent Context Bloat
by u/Parking-Kangaroo-63 in PromptEngineering