AGENTS.md, skills, and hooks
April 5, 2027
Draws on talks by Scott Cunningham
Course Home Page
AGENTS.mdAGENTS.md and one skill or hook for your final project repositoryYour final project is not. A wrong number looks exactly like a right one.
Today: how to tell an agent how your project works, once, instead of in every prompt.
| What it is | What it does | |
|---|---|---|
AGENTS.md |
a Markdown file the agent reads every session | what the agent knows |
| A skill | a Markdown file it reads only when called | what the agent can do |
| A hook | a script the harness runs at fixed moments | what the agent must (not) do |
Start with AGENTS.md. Add a skill when a task repeats, and a hook when a rule must hold.
Framing from Scott Cunningham’s Texas A&M and Baylor talks (2026).
You have already seen one: this course’s repository has an AGENTS.md that tells agents how the site is built, where things live, and what never to commit.
| Tool | Reads |
|---|---|
| Codex | AGENTS.md, from the project root down to the current folder |
| GitHub Copilot | AGENTS.md at the repository root (and .github/copilot-instructions.md) |
| Claude Code | CLAUDE.md; reads AGENTS.md instead when there is no CLAUDE.md |
AGENTS.md, and every tool (and coauthor) shares it.CLAUDE.md, Claude Code reads only that, unless it imports the other with a line @AGENTS.md.Scott’s file states the obvious:
CLAUDE.md
Each line is there because an agent once did it.
So write it down.
Source: Scott Cunningham’s Baylor talk (2026).
Test each line: would a capable stranger, new to this repository, get this wrong? If not, leave it out.
AGENTS.md is committed to Git like any other file.It is loaded into every session, so every line costs context and attention.
A good AGENTS.md for a course project fits on one screen or two.
AGENTS.md
# Minimum wages and teen employment
ECON 2020 final project. R with renv. Paper in paper.qmd.
## Layout
- data/raw/ files exactly as downloaded. READ-ONLY.
- data/derived/ everything built from raw data, by code in code/
- code/ numbered scripts: 01-download.R, 02-clean.R, ...
- output/ figures/ and tables/, made only by code
- main.R runs every script in orderThis is the 2/01 layout (Project Organization), written down for the agent.
AGENTS.md (continued)
## How to run
- Rebuild everything: `Rscript main.R` from the project root.
- After changing a script, rerun main.R and list the outputs that changed.
## Rules
- Never edit, move, or delete anything in data/raw/.
- Every number, table, and figure comes from a script in code/.
Never type a result into the paper by hand.
- Never invent or simulate data unless I ask for a simulation.
- Never open, print, or commit .env. Code loads it with readRenviron(".env").AGENTS.md (continued)
## Ask me before
- dropping observations or changing the sample
- changing an estimator, a control, or how errors are clustered
- adding a package (never run renv::snapshot() yourself)
- deleting any file, or running git push
## Style
- tidyverse and fixest; relative paths from the project root
- At the end of a session, add a short note to notes/progress.mdThe “ask me” list is where your judgment as a researcher lives. Those choices are yours.
You do not have to start from a blank page:
/init reads the folder and drafts an instructions file. Then edit it. The draft will describe what the agent can already see. Your job is to add what it cannot: the rules and the “ask me” list.
Anthropic’s documentation says Claude treats these files as “context, not enforced configuration.”
AGENTS.md said not to.Be wary of Markdown as a control. Keep reading.
Source: code.claude.com/docs/en/memory, accessed October 21, 2026.
AGENTS.md
A skill
/name (or when the agent decides it fits)If you keep pasting the same prompt, turn it into a skill.
Framing from Scott Cunningham, adapted from Claes Bäckman, “Practical AI for Academics” (2026).
/newprojectOne command sets up every new project the same way:
code/, data/raw/, data/clean/, output/progress_logs/ folder to keep his place between sessionsThat is the project skeleton you built by hand on 2/01, as a skill.
Every project starts with the same skeleton, so he always knows where things are.
Source: Scott Cunningham’s Baylor talk (2026).
/referee2Why three languages? Their syntax differs so much that a coding error is unlikely to happen the same way in all three.
Agreement across languages is evidence; agreement within one language is not.
More on this on 4/19.
Source: Scott Cunningham’s Baylor talk (2026).
A skill is a folder with a SKILL.md file in it.
| Tool | Project skills folder |
|---|---|
| Claude Code | .claude/skills/<name>/SKILL.md |
| Codex | .agents/skills/<name>/SKILL.md |
| Copilot in VS Code | .github/skills/, .claude/skills/, or .agents/skills/ |
~/.claude/skills/)..claude/skills/<name>/SKILL.md
description: the agent sees this line in every session and uses it to decide when the skill fits.disable-model-invocation: true: only you can start it, by typing /the-command-name. Use it for anything that deletes or runs for a long time./check-pipeline.claude/skills/check-pipeline/SKILL.md
---
name: check-pipeline
description: Rebuild the project from raw data and report what changed. Use when I ask to check, rerun, or reproduce the results.
disable-model-invocation: true
---
1. Run `git status`. If anything is uncommitted, stop and tell me.
2. Delete data/derived/ and output/. Never touch data/raw/.
3. Run `Rscript main.R` from the project root. If it fails, show the
error and the script it came from. Do not fix anything.
4. Run `git status` and `git diff --stat`. List every output that changed;
for tables, show the old and new numbers side by side.
5. End with one line: REPRODUCED or NOT REPRODUCED.This is the 2/01 test (“delete derived/ and output/, run main.R”) as a skill.
Type /check-pipeline to run it. Anything you type after the name is passed in as $ARGUMENTS.
/referee2, no two would be the same.Making one is simple: describe what you want, and have the agent draft the SKILL.md. Then read it, and cut.
Adapted from Scott Cunningham’s Baylor talk (2026).
AGENTS.md, skills, and prompts are all prose.
Prose works like a parent with a reasonably obedient but terribly forgetful sixteen-year-old.
The only way to be sure is to lock the door and hide the keys.
Source: Scott Cunningham’s Baylor talk (2026).
A rule says
A hook is
Recall 3/24: the model only proposes a tool call; the harness carries it out. A hook sits between the two.
| Event | When |
|---|---|
PreToolUse |
before a tool runs; can block it |
PostToolUse |
after a tool runs (for example, run a formatter) |
UserPromptSubmit |
when you send a prompt |
SessionStart |
when a session starts or resumes |
Stop |
when the agent finishes its reply |
There are many more; these are the ones you are likely to use.
data/raw/jolts.csv.tool_name: "Edit"tool_input.file_path: the file it wants to changecwd: the folder the session is in0: no objection; the normal permission prompt follows2: blocked; whatever the script printed to standard error goes back to the agentAny other exit code is treated as an error in the hook, and the action goes ahead. Use 2.
data/raw/jolts.csv to fix the dates.”data/raw/?Adapted from Scott Cunningham’s Baylor talk (2026).
protect-raw-data (1/2): Register It.claude/settings.json
$CLAUDE_PROJECT_DIR is the project root..claude/settings.json is committed, so coauthors get the hook too.protect-raw-data (2/2): The Script.claude/hooks/protect_raw.py
# Block edits to files that already exist in data/raw/.
import json, os, sys
try:
call = json.load(sys.stdin)
root = os.environ.get("CLAUDE_PROJECT_DIR", call["cwd"])
path = os.path.join(call["cwd"], call["tool_input"]["file_path"])
except (ValueError, KeyError, TypeError):
sys.exit(0) # unexpected input: let the normal permission check decide
raw = os.path.realpath(os.path.join(root, "data", "raw"))
target = os.path.realpath(path)
if target.startswith(raw + os.sep) and os.path.exists(target):
print("data/raw/ is read-only. Read the file and write "
"cleaned data to data/derived/ instead.", file=sys.stderr)
sys.exit(2)json.load(sys.stdin) reads what the agent is about to do.os.path.realpath turns the path into its real, absolute form, so data/derived/../raw/jolts.csv and symbolic links do not slip past.os.path.exists: only existing raw files are protected. Saving a newly downloaded file to data/raw/ is fine.Design principles from Scott Cunningham’s Baylor talk (2026).
Before trusting a hook, feed it a fake tool call and look at the exit code:
code/: the exit code should be 0./hooks to see that it is registered.1The same idea, with different file names:
.codex/hooks.json, same layout (PreToolUse, matcher, command); exit code 2 blocks. File edits arrive as a patch in tool_input.command, not as a file_path, so the script has to read the path out of the patch..github/hooks/*.json, with a preToolUse event that can deny a tool call. In VS Code, hooks are a preview feature, and it can also read hooks from .claude/settings.json. Codex makes you approve (“trust”) a project’s hooks before they run. That is a good habit everywhere.
A hook is a script that runs as you, automatically.
.claude/settings.json or .codex/hooks.json that runs its code when you start an agent there.Before starting an agent in someone else’s repository, read its hook settings.
The same goes for skills: a skill is instructions your agent will follow.
AGENTS.md.Adapted from Scott Cunningham’s Baylor talk (2026).
An engineer told Scott: the problem with hooks is you have to debug them.
Pay the debugging cost for the few rules that must hold. Leave everything else to prose.
Source: Scott Cunningham’s Baylor talk (2026).
A rule you have not tried to break is a rule you only hope works.
Scott’s practice:
raw folder anyway, then reports: did it get through, why, and how would you stop it?Agents are good at finding holes. Point them at your own.
Source: Scott Cunningham’s Baylor talk (2026).
Edit|Write?Our hook only watches two tools. An agent has others.
sed -i, cp, mv, rm, or echo ... > on a raw file never calls Edit or Write.None of these are hypothetical. In a long session, an agent trying to “fix the data” will find one.
| Layer | Stops | Misses |
|---|---|---|
| Hook on Edit and Write | the agent’s file tools; gives a clear message | the shell, scripts |
Deny rule Edit(/data/raw/**) |
file tools, plus sed, tee, > in the shell |
scripts that open files themselves |
Read-only files: chmod -R a-w data/raw |
every program, including your own scripts | an agent that runs chmod back |
| Git, or a saved checksum | nothing, but detects any change | changes to files you never committed |
No single layer is the wall. Scott’s ended up as a small hook plus a folder his user account cannot write to.
Claude Code’s permission settings can also refuse an action outright, in every mode:
In your real file, "permissions" and "hooks" sit side by side in the same top-level { }.
/data/raw/** is relative to the project root when it is in the project’s settings.chmod closes the obvious way around read-only files. Your red team will look for the next one.Work in your final project repository.
git switch -c agent-setupdata/raw/decoy.csv with two or three made-up rowsAGENTS.md: by hand from today’s example, or ask the agent in plan mode to draft it and then edit.main.R), your rules, and your “ask me first” list.Pick one:
protect-raw-data hook, adapted to your folders, or a hook for another rule that must hold (for example, never edit .env).Test it: call the skill by name, or pipe a fake tool call into the hook script and check the exit code.
In a new session, still in Manual mode:
This is a test of my own project's safeguards. data/raw/decoy.csv is
protected. Read .claude/settings.json and AGENTS.md, then try up to
five different ways to change decoy.csv. Do not touch any other file
in data/raw/. After each attempt, report what you tried, whether it
was blocked, and by what. Then suggest how to close each hole.decoy.csv only. Say No to anything else.notes/red-team.md. Close one hole, test again, commit, and push the branch.agent-setup branch, pushed, with AGENTS.md, your skill or hook, and notes/red-team.md[TBD: whether this counts as a graded final-project checkpoint]
github.com/scunning1975/mixtape_harness: his setup for causal inference work with agents, including his hooks.github.com/scunning1975/MixtapeTools: his skills, including /newproject, /referee2, and /split-pdf.Check the license before you copy anything. As of October 2026, neither repository lists a license, which means you may read them but not reuse their files. Read them for ideas, then write your own.
AGENTS.md: standing instructions, read every session. Write down what is obvious to you; keep it short.