⚡ PromptLoot

Home › Coding & Cursor Rules

Generate AGENTS.md or CLAUDE.md From Your Repo

A prompt that makes your coding agent read the repo, ask only what it can't find out, run every command it plans to write down, and save a short, accurate AGENTS.md or CLAUDE.md.

Added

You are writing the rules file for this repository: AGENTS.md (and a CLAUDE.md that only contains @AGENTS.md, if I use Claude Code). The file must be short and every fact in it must be true for this repo today.

## Step 1: Read, don't guess
Inspect the repo before writing anything: README, package/manifest files (package.json, pyproject.toml, Cargo.toml, go.mod, etc.), lockfiles, CI config, Makefile or task runner, existing rules files (.cursorrules, .cursor/rules, copilot-instructions.md, old CLAUDE.md), test folders, and a few representative source files.
Write down what you found: language and framework versions, package manager (from the lockfile, not a guess), how tests, lint, typecheck, build, and dev server are run, folder layout, and any patterns repeated across files.

## Step 2: Ask me only what the repo can't tell you
At most 5 questions, e.g. which folders are off-limits, what must never be changed without asking, deploy rules, which conventions are deliberate. If the repo answers it, don't ask.

## Step 3: Verify every command
Run each command you plan to include (install, test, lint, typecheck, build). For each, record: the exact command, whether it passed, and how long it took. Only commands that ran correctly go in the file. List any that failed separately with the error, and don't paste them in as if they work. Never run deploy, publish, migration, or anything that touches production; ask me instead.

## Step 4: Write the file (under 40 lines)
# [Project name]
One sentence: what this is.
## Stack
Only decisions an agent could get wrong (framework, package manager, data layer, test tool).
## Commands
The verified commands, exactly as run.
## Layout
3 to 6 lines: where things live.
## Rules
3 to 6 rules that change behavior here, each concrete and checkable (e.g. "Run pnpm test:unit before saying done"). No generic advice like "write clean code".
## Ask first
Things the agent must not do without asking.

## Step 5: Report
- The file.
- A table of commands: command, result, time.
- What you left out and why (rules from old files that were outdated, duplicated, or untestable), so I can add anything back.
- Old rules files that can now be deleted or turned into one-line pointers to AGENTS.md.

Rules: no secrets or .env values in the file; if two sources disagree (README vs CI), trust what actually ran and tell me about the conflict.

How to use it

  1. Click Copy template.
  2. Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
  3. Replace the [BRACKETED] parts with your details.

Pairs well with: AI Agent Harness Starter Pack: Rules, Hooks, Status & Verify

Sponsor this page · Reach builders who use AI daily. Get details

FAQ

Can an AI agent write its own CLAUDE.md or AGENTS.md?

Yes, and it's often the fastest way to get a good one, as long as it reads the repo first and runs each command it writes down. Unverified rules files are where wrong commands and outdated rules come from.

Why verify the commands?

Because the commands section is what the agent relies on most. A wrong test or build command means every later session wastes time or reports success without really checking.

How is this different from Claude Code's /init?

/init drafts a CLAUDE.md from the repo. This prompt adds a short question round, runs every command before saving it, keeps the file under 40 lines, writes AGENTS.md so other agents share it, and lists what it left out.

How long should AGENTS.md be?

Short. Codex, for example, only reads a limited amount of AGENTS.md text (32 KiB by default across all the files it combines), and long files bury the rules that matter. Aim for under 40 lines in the root file.

Get 3 new templates every week

Free. Unsubscribe anytime.

Related templates

AGENTS.md Starter Template for Claude Code, Codex & Cursor

A drop-in AGENTS.md (or CLAUDE.md) that tells coding agents how your repo works, how to verify changes, and what never to touch.

Lean CLAUDE.md: Trim a Bloated Rules File to 40 Lines

Your agent ignores half of a long CLAUDE.md or AGENTS.md. This prompt cuts it to a lean core (stack, commands, a few never-do rules) and moves the rest into imported files.

One Rules File for Claude Code, Codex, Cursor & Gemini

Stop CLAUDE.md, AGENTS.md, GEMINI.md, and Cursor rules drifting apart: one AGENTS.md source of truth plus tiny pointer files for every agent.

Rules File Drift Check: Is Your AGENTS.md Lying to the Agent?

A prompt that checks CLAUDE.md, AGENTS.md, GEMINI.md, and Cursor rules against the real code and against each other, and flags stale or contradictory lines before your agent follows them.

This Codebase Is Yours: Ownership Rules for Coding Agents

Rules-file lines that tell Claude Code, Codex, or Cursor it owns the code, so it edits and removes code instead of bolting on duplicate functions and wrappers.

Browse all Coding & Cursor Rules templates

New on PromptLoot

2D Game Asset Rules for AI Agents: Sprites & Colliders

An ASSETS.md for Claude Code, Cursor, or Codex in Godot, Unity, Phaser, or Canvas: sprite sheet layout, naming, pixel-art import, animations, and colliders.

Agent Auto-Approve Policy: What AI Agents May Merge Alone

A policy file that sorts every PR an AI agent reviews into auto-merge, human review, or blocked: docs and tests yes; payments, auth, and secrets never.
PromptLoot Pro Pack · 200+ advanced templates, agent workflows, and Cursor rules bundles. Coming soon