Your Agent Is Only As Good As Its Context
We spend hours tweaking prompts and debating which flagship model writes better code. Yet when an AI coding agent ignores a critical rule, hallucinates a command, or gets stuck in an infinite test-fixing loop, the culpri
We spend hours tweaking prompts and debating which flagship model writes better code. Yet when an AI coding agent ignores a critical rule, hallucinates a command, or gets stuck in an infinite test-fixing loop, the culprit is rarely the model.
It’s the context we fed it.
Hand even the strongest model a CLAUDE.md, AGENTS.md, or .cursorrules file that is ambiguous, stale, bloated, or unsafe, and the agent won't stop to complain—it will guess, plausibly and silently. Then you pay the price to notice, diagnose, and undo the guess.
To solve this, I built "good-context" — an open-source Claude Code skill (and standalone Python linter) that audits, fact-checks against your actual repository, and repairs the instruction files your AI agents read.
GitHub Repo: https://github.com/wachirawitc/good-context
Grounded in Research: The CAFE(S) Framework
Instead of inventing arbitrary prompt-engineering rules or fake "7/10" quality scores, good-context applies the CAFE(S) context-quality framework from the 2026 ACM Queue paper, "CAFE(S): Your Agent Is Only As Good As Its Context" (by Brian Houck, Max Kanat-Alexander, Eirini Kalliamvakou, Margaret-Anne Storey, and Nicole Forsgren): https://queue.acm.org/doi/10.1145/3847288
CAFE(S) evaluates agent context across 5 independent dimensions:
Clarity — Can the agent interpret it as intended?
(Fails when instructions have several plausible readings, so the agent silently picks one and edits the wrong service.)Actionability — Can the agent proceed, and know when it is done?
(Fails when there is no clear goal, prohibitions with no alternatives, or no finish line, causing infinite retry loops.)Fidelity — Can the agent trust that it is true?
(Fails due to stale paths, deleted npm scripts, or version drift like saying Node 18 in docs when .nvmrc says Node 20.)Efficiency — Can the agent focus on what matters?
(Fails when signal is buried in noise, or file-specific edge cases sit in a root CLAUDE.md loaded into every single session.)(S)ecurity — Should the agent have this at all?
(Fails when files contain plain-text credentials, hidden HTML/Unicode prompt injections, or route untrusted issue text into commands.)
Named "Context Smells"
Just like "code smells" give engineers a shared vocabulary for design issues, good-context detects and names 19+ Context Smells in your documentation:
• Stale Guidance (Fidelity): Commands or paths that existed six months ago (e.g., npm run test:unit) but have since been removed from package.json.
• Referential Ambiguity (Clarity): Saying "update the database" or "restart the service" when the monorepo has both Postgres and Redis, or three microservices.
• Negative-Constraint Fragility (Actionability): Writing "NEVER use the ORM directly" without telling the agent what to use instead or why.
• Goal Drift (Actionability): Saying "Make the tests pass" without guardrails—leading the agent to delete or loosen failing tests instead of fixing the bug.
• Weekend Runaway (Efficiency + Actionability): Open-ended instructions like "Keep trying until it works" with no bound on attempts.
• Lost in the Middle (Efficiency): Burying the most important build rule at bullet #28 of a 500-line file full of generic advice ("You are an expert senior engineer, write clean code").
• Paste-in-the-Prompt Leak & Indirect Prompt Injection (Security): Hardcoded staging DB passwords or hidden instructions inside HTML comments / invisible Unicode.
Getting Started in 30 Seconds
- Install the Skill for Claude Code Clone the repository and copy the good-context folder into your personal Claude Code skills directory (~/.claude/skills/):
git clone https://github.com/wachirawitc/good-context.git
cd good-context
mkdir -p ~/.claude/skills
cp -r good-context ~/.claude/skills/
- Run It in Claude Code Start a new Claude Code session in any project and run:
- Review + Auto-Fix:
/good-context @CLAUDE.md - Review Only (no edits):
/good-context --review @CLAUDE.md - Update Only (fast fix):
/good-context --update @AGENTS.md
You can also trigger it naturally by asking: "Audit my CLAUDE.md" or "Why does the agent keep ignoring my test rules?"
How good-context Works
When you run "/good-context @claude.md", the skill runs a 6-step workflow:
Situates the file: Determines the file's Role and Reach. A root CLAUDE.md is paid for in every single session, so it gets a strict Efficiency and Fidelity pass. A one-off task brief gets a strict Actionability pass.
Gathers mechanical evidence: Runs a bundled zero-dependency Python linter (context_lint.py) that checks token counts per section, broken file paths, missing package.json / Makefile commands, version drift, hidden Unicode, and secret patterns.
Verifies against reality: Cross-checks every concrete claim against your repo's actual package.json, .nvmrc, lockfiles, directory tree, and neighbor docs (README.md, AGENTS.md).
Reads the file cold: Evaluates the text from the perspective of a newly onboarded engineer who only has this file and the repo.
Produces a structured report: Ranks findings by severity (🔴 Critical → 🟠 High → 🟡 Medium → ⚪ Low) with exact line numbers, evidence from your repo, and concrete fixes.
Repairs without guessing: Applies verified fixes, trims noise, relocates misplaced rules, and explicitly asks you about ambiguous intent (it never fills a gap with a guess).
If you find it useful, a ⭐ on GitHub would mean a lot!
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.