{
  "id": 11403822,
  "title": "Your agent's instructions file is a suggestion. A hook is a contract.",
  "url": "https://urgent.news/2026/10/02/your-agents-instructions-file-is-a-suggestion-a-hook-is-a-contract",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-02T09:12:06.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/alphanumericentity/your-agents-instructions-file-is-a-suggestion-a-hook-is-a-contract-1eak"
  },
  "original_language": "en",
  "account": "When you write an instructions file for a coding agent, it's merely a suggestion. A hook, on the other hand, is a contract that the agent must follow. The author found that their long instructions file often went unheeded. The agent only follows those rules when the context is simple, the task is uninteresting, and the rule is salient. However, it's precisely during the moments when the file is lengthy, the task is intriguing, and the rule is the least noticeable in a 30k-token context that the agent needs the rule most.\n\nBy moving the critical rules into PreToolUse hooks, the agent becomes less bothersome to supervise. The mechanics of a PreToolUse hook are straightforward: it's a program that gets called by a tool with its JSON input. The hook decides whether to proceed with the tool or block its execution. The key difference between a hook and an instructions file is that the call never happens in the case of a hook. The model is discouraged from the action, and instead, the hook returns a refusal. The reason is then communicated back to the model, which enables it to self-correct, avoiding a costly round trip through the agent's attention.\n\nThe hook is effective, and its reasoning is communicated clearly. For instance, a hook that blocks mass deletes from the production database prevents any accidental data loss. Another hook that blocks local type-checking saves valuable CPU resources. A hook that blocks multi-line comments prevents the quiet shifting of timestamps and the silent ramping of feature flags. These rules, which are grouped based on what they protect, ensure that the agent doesn't violate certain critical guidelines.\n\nThese hooks, while effective, come with a price. False positives occur, and they're the cost of implementing such strict rules. The author has to edit the hooks to accommodate rare exceptions, but this is still cheaper than the alternative – an agent that blindly carries out its tasks without oversight. Hooks are crucial for the few rules where 'usually' isn't sufficient. The author initially implemented hooks due to their lack of trust in the model, but this perspective has since changed.",
  "summary": "Every coding agent now reads an instructions file. CLAUDE.md , AGENTS.md , .cursorrules , whatever yours is called. Mine is long. It has been long for months, because every time something went wrong I did the obvious thing and wrote a sentence about it. Here is what I eventually noticed. The agent follows those sentences most of the time. Not always. And the times it doesn't are not random:…",
  "key_points": [
    "Instructions file for coding agents is merely a suggestion, not a strict rule.",
    "PreToolUse hooks act as contracts, compelling the agent to follow critical rules.",
    "Hooks prevent costly mistakes, like accidental data loss or CPU resource waste."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}