Agent Playbook

Version: 0.0.5

Status: Draft

Purpose: A portable, tool-agnostic playbook for structuring LLM agent context, memory, rules, and documentation inside any software project.


Philosophy

Agent behavior is code. It should be versioned, reviewed, modular, and readable by both humans and machines. The .agents/ folder is the single source of truth for everything an LLM agent needs to operate within a project β€” permissions, instructions, skills, memory, commands, and documentation artifacts.

Core Principles


Folder Structure

project-root/
β”œβ”€β”€ AGENTS.md                  # Primary instruction file + table of contents
└── .agents/
    β”œβ”€β”€ rules/                 # Modular instruction files
    β”‚   └── <rule-name>.md
    β”œβ”€β”€ skills/                # Context-invoked workflows
    β”‚   └── <skill-name>/
    β”‚       └── SKILL.md
    β”œβ”€β”€ commands/              # Custom slash commands
    β”‚   └── <command-name>.md
    β”œβ”€β”€ agents/                # Subagent personas
    β”‚   └── <agent-persona>.md
    └── memory/                # Persistent agent memory
        β”œβ”€β”€ MEMORY.md          # Long-term memory. Durable facts, preferences, and decisions
        └── YYYY-MM-DD.md      # Daily notes (UTC timezone). Running context and observations

File & Folder Reference


AGENTS.md β€” Primary Instruction File

Think of AGENTS.md as a README for agents: a dedicated, predictable place to provide the context and instructions an AI coding agent needs to work on your project.

The agent’s entry point. Every runtime MUST load this file first. It serves two roles:

  1. System prompt β€” High-level instructions, persona, tone, and behavioral defaults.
  2. Table of contents β€” An index of all active agent files so the runtime knows what else to load.

Schema

# Agent Instructions

## Setup commands

[Commands an agent may need to run, e.g. install, dev, test, lint, build]

## Code style

[Language and style conventions β€” TypeScript strict mode, single quotes, etc.]

## Loaded Context

<!-- The runtime uses this section to discover and load other files -->

| File                                  | Purpose              | Auto-load |
| ------------------------------------- | -------------------- | --------- |
| rules/code-style.md                   | Coding conventions   | yes       |
| rules/security.md                     | Security constraints | yes       |
| commands/review.md                    | /review command      | on-demand |
| memory/MEMORY.md                      | Long-term memory     | yes       |
| ../docs/auth-redesign/ARCHITECTURE.md | Task architecture    | on-demand |

Rules


rules/ β€” Modular Instruction Files

Granular, composable instruction files. Each file governs a single concern. Rules are injected into the context window based on relevance or the Auto-load setting in AGENTS.md.

Use rules/ for scoped or conditional guidance. If a rule should run for every task, keep it in AGENTS.md instead.

Naming Convention

rules/<name>.md

Examples: rules/code-style.md, rules/security.md, rules/testing.md, rules/git-workflow.md, rules/api-conventions.md

File Schema

---
name: Code Style
description: Enforces project coding conventions
applies_to: ["**/*.ts", "**/*.tsx"]
priority: high
---

# Code Style Rules

- Use 2-space indentation
- Prefer `const` over `let`; never use `var`
- All exported functions must have JSDoc comments
  ...

Rules


skills/ β€” Context-Invoked Workflows

Skills are pre-defined workflows that the agent can load when the current task matches their metadata, or when the user invokes them directly. They are the agent’s reusable procedures.

Naming Convention

skills/<name>/SKILL.md

Examples: skills/on-new-file/SKILL.md, skills/on-test-fail/SKILL.md, skills/on-pr-open/SKILL.md, skills/on-commit/SKILL.md

File Schema

---
name: on-new-file
description: Auto-generates a matching test file when a new TypeScript file is created
when_to_use: Use when creating or updating TypeScript source files that may need matching tests.
paths: ["src/**/*.ts"]
---

# Skill: On New File

## When to Use

Use when a new `.ts` file is created in `src/`.

## Workflow

1. Inspect the new file and identify exported functions/classes.
2. Check if a corresponding `.test.ts` file exists in `src/__tests__/`.
3. If not, generate a scaffold test file using the project's test conventions (see `rules/testing.md`).
4. Notify the user: "Created test scaffold at `[path]`."

## Output

- Creates: `src/__tests__/<filename>.test.ts`
- Notifies: Yes

Metadata

Required:

Optional:

Rules


commands/ β€” Custom Slash Commands

Explicit, user-invoked operations exposed as slash commands (e.g., /review, /scaffold).

Naming Convention

commands/<name>.md

Examples: commands/review.md, commands/scaffold.md, commands/deploy-check.md, commands/summarize.md

File Schema

---
name: review
description: Performs a structured code review on staged or specified files
argument-hint: "[target]"
arguments: [target]
disable-model-invocation: true
---

# Command: /review

## Usage

```text
/review [target]
/review src/auth/login.ts
/review staged
```

## Behavior

1. Load `rules/code-style.md` and `rules/security.md`.
2. Diff the target against `main` (or review the full file if untracked).
3. Produce a structured review in the following format:

### Review Format

**Summary:** [One-line verdict]

**Issues:**
| Severity | Line | Description |
|----------|------|-------------|
| πŸ”΄ Critical | 42 | SQL injection risk β€” user input not sanitized |
| 🟑 Warning | 88 | Missing null check before `.data` access |
| πŸ”΅ Info | 12 | Consider extracting magic number `3600` to a constant |

**Suggestion:** [Optional refactor idea]

Rules


agents/ β€” Subagent Personas

Specialized agent personas that can be invoked for specific tasks. Each subagent has its own identity, capabilities, and behavioral constraints.

Naming Convention

agents/<name>.md

Examples: agents/reviewer.md, agents/architect.md, agents/debugger.md, agents/writer.md, agents/security-auditor.md

File Schema

---
name: Architect
invoke: "@architect"
description: Senior software architect focused on system design and technical decisions
inherits: ["rules/general.md"]
overrides:
  temperature: 0.2
  tools: ["file_read", "web_search"]
---

# Subagent: @architect

## Identity

You are a senior software architect with 15 years of experience designing scalable distributed systems. You are opinionated, precise, and always consider long-term maintainability over short-term convenience.

## Responsibilities

- Evaluate architectural decisions and trade-offs
- Produce or review `docs/[YYYY-MM-DD-task-name]/ARCHITECTURE.md`
- Advise on technology choices with explicit rationale
- Flag designs that will not scale or will create debt

## Behavioral Constraints

- Never write implementation code β€” only design, diagrams, and guidance
- Always provide at least two alternatives before recommending one
- Cite `docs/[YYYY-MM-DD-task-name]/ARCHITECTURE.md` when context is available
- Use ADR (Architecture Decision Record) format for major decisions

## Output Format

Use structured Mermaid diagrams for system visualizations.

Rules


memory/ β€” Agent Memory

Persistent storage of facts, decisions, entities, and context that should survive across sessions.

File Purpose
MEMORY.md Long-term memory. Durable facts, preferences, and decisions
YYYY-MM-DD.md Daily notes (UTC timezone). Running context and observations

MEMORY.md Schema

# Memory

## Facts

- **Project uses Postgres** β€” Primary database since 2025-01
- **@alex is lead engineer** β€” Owns payment module

## Preferences

- **Code review** β€” Prefers concise PR reviews with clear action items
- **Testing** β€” Requires 80% coverage minimum

## Decisions

### [2025-05-01] Use Postgres over MongoDB

**Context:** Evaluating database for user profile storage.
**Decision:** Chose Postgres for its relational integrity.
**Revisit if:** Need to store unstructured event data at scale.

YYYY-MM-DD.md Schema

# 2025-05-01 (UTC)

## Context

Working on user authentication feature.

## Observations

- Found that JWT refresh token rotation is not implemented
- AuthService currently lacks token blacklist

## Next Steps

- [ ] Implement JWT refresh token rotation
- [ ] Add rate limiting to login endpoint

Rules


Adoption Guide

Minimal Setup (< 5 min)

AGENTS.md

Start with just a AGENTS.md. Write your agent instructions. Add folders as needs emerge.


Playbook Setup

AGENTS.md
.agents/
β”œβ”€β”€ rules/
β”‚ β”œβ”€β”€ general.md
β”‚ └── code-style.md
└── memory/
    └── MEMORY.md

Full Setup

Add skills/, commands/, and agents/ as the project matures.


Runtime Expectations

A compliant runtime MUST:

  1. Always load AGENTS.md at session start.
  2. Enforce permissions defined in AGENTS.md before any file operation.
  3. Auto-inject all files marked Auto-load: yes in AGENTS.md.
  4. Load skills whose description, when_to_use, or paths match the current context.
  5. Register commands from commands/ and expose them via the invocation interface.
  6. Respect subagent boundaries β€” a subagent must not exceed the parent agent’s permissions.

A compliant runtime SHOULD:


Versioning & Compatibility


Security Considerations


Reference Implementation

This repository uses itself as the reference implementation. The .agents/ folder at the root of this repo is the maintained set of playbook-conformant assets used for its own development β€” governing how agents should assist with writing, reviewing, and evolving the spec itself.

agent.md/ ← this repo
β”œβ”€β”€ .agents/ ← maintained agent asset library
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ rules/
β”‚   β”‚ β”œβ”€β”€ writing-style.md
β”‚   β”‚ └── contribution.md
β”‚   β”œβ”€β”€ skills/
β”‚   β”‚ └── on-new-example/
β”‚   β”‚     └── SKILL.md
β”‚   β”œβ”€β”€ commands/
β”‚   β”‚ └── validate.md
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚ └── spec-reviewer.md
β”‚   └── memory/
β”‚       └── MEMORY.md
β”œβ”€β”€ README.md
└── pages/
    β”œβ”€β”€ index.md
    β”œβ”€β”€ AGENT_PDLC.md
    └── PLAYBOOK.md

Browse the .agents/ folder directly to see maintained playbook-conformant assets.

See AGENT_PDLC.md for the lifecycle diagram used when humans and agents collaborate on product development work.


Example: Real Project Layout

my-saas-app/
β”œβ”€β”€ .agents/
β”‚   β”œβ”€β”€ rules/
β”‚   β”‚ β”œβ”€β”€ code-style.md       # TypeScript conventions
β”‚   β”‚ β”œβ”€β”€ testing.md          # Test coverage requirements
β”‚   β”‚ └── security.md         # OWASP top-10 awareness
β”‚   β”œβ”€β”€ skills/
β”‚   β”‚ β”œβ”€β”€ on-new-file/        # Auto-scaffold test files
β”‚   β”‚ β”‚ └── SKILL.md
β”‚   β”‚ └── on-test-fail/       # Diagnose CI failures
β”‚   β”‚     └── SKILL.md
β”‚   β”œβ”€β”€ commands/
β”‚   β”‚ β”œβ”€β”€ review.md           # /review β€” structured code review
β”‚   β”‚ └── scaffold.md         # /scaffold β€” generate boilerplate
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚ β”œβ”€β”€ architect.md        # @architect β€” system design advisor
β”‚   β”‚ └── security-auditor.md # @security β€” OWASP-focused review
β”‚   └── memory/
β”‚       └── MEMORY.md
β”œβ”€β”€ src/
β”œβ”€β”€ tests/
β”œβ”€β”€ package.json
└── README.md

This playbook is intentionally tool-agnostic. Implementations may extend it with runtime-specific features provided they do not break compatibility with this core specification.