Home
cd ../playbooks
Developer ToolsAdvanced

Writing for AI Agents: A Craft Reference

A theory of writing any document an agent consumes — skills, CLAUDE.md, reference docs — built on context pointers, an information hierarchy of steps versus disclosed reference, completion criteria, and leading words that anchor behavior in the fewest tokens.

10 minutes
By Matt PocockSource
#claude-md#skill-authoring#prompt-engineering#documentation#agent-design#context-management

A skill or CLAUDE.md that half-works isn't usually wrong — it's just badly engineered as a document: the wording of one pointer decided whether the agent ever reached the rule that mattered, and nobody was thinking about that when it got written.

Who it's for: developers writing or maintaining CLAUDE.md and AGENTS.md files, skill authors trying to make triggering reliable, teams whose agent docs have grown long and inconsistent, anyone who wants a systematic craft for writing documents an agent actually follows instead of trial-and-error prompting

Example

"My CLAUDE.md keeps missing rules and my skill barely triggers" → A diagnosis using context pointers (is the wording sharp enough to fire the branch that matters?), the information hierarchy (should this be an in-file step, in-file reference, or pushed behind a pointer?), and a pruning pass that hunts no-ops and duplication sentence by sentence — restructured, not just trimmed

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

Or install from your terminal:
npx ccplaybooks add writing-for-ai-agents
# Writing for AI Agents — A Craft Reference

Reference for writing any document an AI agent consumes: a skill, a `CLAUDE.md`/`AGENTS.md`, a reference doc reached by a pointer. The packaging differs; the writing doesn't — the same levers make each one predictable, because the agent takes the same *process* every run rather than producing the same output a human writer would.

Use this whenever you're drafting or editing a skill, a `CLAUDE.md`, or any doc an agent is meant to follow reliably.

## Context Pointers

A **context pointer** is a reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. A skill's description is one; a line in `CLAUDE.md` naming a doc is the same object. The pointer's *wording*, not its target, decides when the agent reaches the material, and how reliably. A must-have target behind a weakly worded pointer is a variance bug: sharpen the wording first, and only inline the material if sharpening fails.

A pointer does two jobs: state what the material is, and list the **branches** that should trigger reaching it (a branch is a distinct case the document handles — different runs take different paths through it). Every word of an always-loaded pointer costs on every turn, so it earns even harder pruning than the body:

Get new playbooks like this one

One email a week with new Claude Code workflows. Free, like everything here.

No spam. Unsubscribe anytime.

README.md

What This Does

A craft reference for writing anything an agent reads and follows every run — a skill, a CLAUDE.md/AGENTS.md, a reference doc reached by a pointer. The core insight: the packaging differs, but the writing doesn't, because the agent takes the same process each time rather than producing a one-off human-readable output. That means the same handful of levers — how a pointer is worded, where material sits on the information hierarchy, how sharp a completion criterion is, whether a concept is anchored with a leading word — decide whether the document actually gets followed.

It covers context pointers (a pointer's wording decides whether it fires, not its target), the information hierarchy of in-file steps versus in-file reference versus disclosed reference, when premature completion happens and how to defend against it, leading words as a token-efficient way to anchor behavior, and a concrete pruning discipline for hunting duplication, staleness, and no-ops sentence by sentence.


Quick Start

Step 1: Create a Project Folder

mkdir writing-for-agents && cd writing-for-agents

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ./

Step 3: Apply It to a Real Document

claude

Then paste in the skill, CLAUDE.md, or reference doc you're struggling with and ask Claude to restructure it using this framework — or ask it to draft a new one from scratch with these principles in mind.


Tips & Best Practices

  • Sharpen a pointer's wording before you inline the material behind it — a must-have target behind a weakly worded pointer is a variance bug, and the cheap fix is almost always wording, not restructuring.
  • When a CLAUDE.md has grown long and the model seems to miss rules buried in the middle, that's the sprawl failure mode. Restructure with the information hierarchy — don't just trim words from individual sentences.
  • Reach for an existing word before coining your own leading word. A pretrained concept (fog of war, tracer bullet) anchors behavior for free; a made-up word costs you the definition tokens a real one gives away.
  • Run the no-op test on every sentence during a pruning pass: does it change behavior versus what the model already does by default? If not, delete the whole sentence rather than trimming it.

Limitations

  • This is a craft reference, not a linter — applying it well still takes judgment about where each specific piece of content belongs on the hierarchy.
  • Pairs well with, but doesn't replace, a dedicated tool for restructuring an already-bloated CLAUDE.md — this playbook is about writing and organizing from the ground up, not a mechanical two-level split.
  • Best suited to documents an agent reads repeatedly across many runs; a truly one-off instruction doesn't need this level of engineering.

$Related Playbooks

Developer Tools

Office MCP Server Setup

MCP server with 39 tools for Word, Excel, PowerPoint, PDF, OCR operations

10 minutes
Intermediate
Developer Tools

Tech Debt Analyzer

Identify, analyze, document, and track technical debt in JavaScript/TypeScript codebases with automated detection and prioritized remediation plans.

10 minutes
Intermediate
Developer Tools

Test Specialist

Comprehensive JavaScript/TypeScript testing guidance with test writing, bug analysis, coverage analysis, and proactive issue detection.

10 minutes
Intermediate
Developer Tools

Accessibility Engineering for Components

Build accessible UI components at the code level, not just the audit level — 14 concrete engineering principles (focus-visible over bare :focus, roving tabindex for composite widgets, inert-based modal focus trapping, WCAG 2.5.8 hit-area minimums), a common-mistakes table with fixes, and a severity-rated review format ending in a hard Block/Needs-changes/Approve verdict.

5 minutes
Intermediate
Developer Tools

Adversary Emulation: MuddyWater

An intelligence-grounded, authorized purple-team emulation profile for MuddyWater (MITRE ATT&CK G0069), Iran's MOIS-linked cyber-espionage group — attribution, targeting, representative TTPs by ATT&CK tactic, emulation guidance mapped to generic red-team tooling, and paired detection/defense recommendations for every offensive technique, all under an explicit authorized-use caveat.

15 minutes
Advanced
Developer Tools

Adversary Emulation: Turla

An intelligence-grounded, authorized purple-team emulation profile for Turla (MITRE ATT&CK G0010), Russia's FSB-linked espionage group — attribution, distinctive TTPs (satellite C2 hijacking, steganographic email backdoors, parasitizing rival APT infrastructure), emulation guidance mapped to generic red-team tooling, and paired detection recommendations, under an explicit authorized-use and lab-only caveat for rootkit techniques.

15 minutes
Advanced
Developer Tools

AI Agent Red Team Methodology

A first-principles methodology for authorized red-team exercises against AI products, agents, MCP servers, skills, and repositories — capability and trust-boundary modeling, AI-specific attack hypothesis families (prompt injection, tool misuse, data leakage, SSRF), harmless-proof testing with canaries, one-variable-at-a-time adaptive iteration, and business-language evidence-based reporting.

10 minutes
Advanced
Developer Tools

Datadog Error Triage to PR

Take Datadog Error Tracking issues from raw occurrence counts to a reviewable, tested PR — a five-class bug taxonomy that filters out infra noise and deploy-skew before ranking, a recency premium that catches fresh regressions early, a mandatory approval gate before any fix is written, and a test-first fix workflow that generalizes past the one reported occurrence.

10 minutes
Advanced
Developer Tools

Agent DX CLI Scale

A 7-axis, 0-21 scoring scale for evaluating how well a CLI is designed for AI agents rather than humans — machine-readable output, raw payload input, schema introspection, context-window discipline, input hardening, safety rails, and agent knowledge packaging.

5 minutes
Intermediate
Developer Tools

Agent Design Philosophy

A mental model for designing AI agents in any domain — the model already knows how to be an agent, so design is about capabilities, knowledge, and context, added only as far as a Progressive Complexity ladder (basic → planning → subagents → skills) that real usage actually demands.

10 minutes
Intermediate
Developer Tools

Agent Prompt Architect

A compact seven-field skeleton (Role, Goal, Inputs, Constraints, Process, Output, Verification, Fallback) and a fast refinement loop for turning vague intent into a prompt an agent can execute reliably every time.

5 minutes
Beginner
Developer Tools

Agent SDK App Builder

Scaffold new Claude Agent SDK applications in TypeScript or Python, and verify existing ones against official SDK patterns before you ship.

10 minutes
Intermediate

Browse all Developer Tools playbooks →