Skip to content

Prerequisites

Agentic Coding Primer

The eight primitives your agent already ships with — the raw parts every loop is assembled from.

The eight primitives your agent already ships with — the raw parts every loop is assembled from.

The hook

You ask your agent to "clean up the failing tests." It edits four files, runs the suite, opens a plan for the one risky change, and stops to ask permission before it touches your CI config. Read your prompt again: none of that was in it. So where did the behavior come from? From eight primitives that were configured before you typed a single word — and loop engineering is, at bottom, the craft of configuring them on purpose instead of by accident.

The eight primitives (plain English)

PrimitiveWhat it isLoop-engineering job
Plan modeAgent proposes before it actsRehearse a loop's behavior safely
PermissionsWhat the agent may do without askingThe L1→L3 ladder lives here
ContextWhat the agent can see (files, history)Keep beats cheap; avoid drowning
Rules fileStanding instructions loaded every sessionA loop's "constitution" (CLAUDE.md, AGENTS.md)
SkillsPackaged, reusable instruction setsA loop's trained moves
HooksCode that runs on agent eventsMechanical guardrails no prompt can skip
SubagentsFocused workers spawned for a subtaskMaker/checker separation
MCP / connectorsBridges to external tools & dataA loop's senses beyond the repo
Diagram

You don't need to master all eight today. You need to know they exist, and to recognize which one you're reaching for when a loop misbehaves later.

See them in your tool

# Claude Code — live docs: https://docs.claude.com/en/docs/claude-code
# rules file:   CLAUDE.md at the repo root (loaded every session)
# permissions:  /permissions   ·  plan mode: shift+tab (or /plan)
# skills:       .claude/skills/<name>/SKILL.md, invoked as /<name>
# hooks:        .claude/settings.json → "hooks"
# subagents:    .claude/agents/<name>.md
# MCP:          claude mcp add <server>
# OpenCode — live docs: https://opencode.ai/docs
# rules file:   AGENTS.md at the repo root
# permissions:  opencode.json → "permission"
# plan mode:    switch agent to "plan"
# skills:       skills/ directory  ·  subagents: "agent" config
# MCP:          opencode.json → "mcp"

[!WARNING] The exact flags and file names drift constantly — the shapes do not. When a command here and the tool's live docs disagree, believe the docs.

[!NOTE] Going deeper: this repo practices what the page preaches — its own CLAUDE.md is a rules file, its loop guardrails live in loop-constraints.md, and its checker runs as a genuinely separate reviewer. Browse them from the repo root once you've read this.

Check yourself

Q: You want an ironclad guarantee that no loop can ever edit .env, even if some prompt cheerfully asks it to. Which primitive — rules file, or hooks/permissions — and why?

Answer

Hooks/permissions. A rules file is an instruction the model reads and (usually) follows — strong, but in the end advisory. Permissions and hooks are enforced by the harness: the edit is blocked mechanically, no matter how the prompt is worded. The rule of thumb worth memorizing: put intent in rules, put guarantees in permissions and hooks.

Try With AI

In your sandbox repo:

  1. Create a CLAUDE.md (or AGENTS.md) with a single rule: "Always run the test suite before claiming a task is done."
  2. Ask your agent to fix any tiny thing, and watch whether it actually obeys the rule.
  3. Then ask it directly: "Which of your eight primitives did that rule use, and which one would make it unbreakable?"

When it goes wrong

SymptomCauseFix
Agent ignores your standing instructionThe rule is buried in a bloated rules fileRules files are context too — keep them short and binding
Agent asks permission for everythingPermission mode too strict for the taskLoosen for the session, not globally; keep write-paths narrow
Agent confidently edits the wrong moduleContext too broad, or gone stalePoint it at specific files; start a fresh session for new work
A "safety rule" got talked aroundThe guarantee lived in prose, not machineryMove it from the rules file into permissions or a hook

Attribution: this page condenses ideas from Panaversity's Agentic Coding Crash Course (S2; see also ../../resources/sources.md).

Glossary terms used on this page: primitive, rules file, hook, subagent, MCP — see ../02-foundations/glossary.md.