AGENTS.md for Monorepos

The root + per-package AGENTS.md pattern for monorepos: nearest-file-wins scoping that keeps agent instructions relevant to the code being edited.

# ROOT FILE: AGENTS.md at the repository root:

# [MONOREPO NAME]

[One sentence: what this monorepo contains, e.g. "pnpm workspace: customer web app, public API, and shared packages."]

## Map
- `apps/web` ([Next.js customer app]) has its own AGENTS.md
- `apps/api` ([Fastify service]) has its own AGENTS.md
- `packages/ui`: [shared component library]
- `packages/config` ([shared tsconfig/eslint) do not modify without asking]

## Repo-wide commands
```bash
pnpm install          # always from the root, never npm/yarn
pnpm turbo run typecheck test lint --filter=[package]...  # verify only affected packages
```

## Repo-wide rules
- Cross-package imports only via workspace aliases (`@repo/ui`), never relative paths reaching into another package's src.
- Shared code changes (`packages/*`) require running the affected downstream apps' tests, not just the package's own.
- One package per PR unless the change is atomic across packages. Say so in the PR title.
- Never edit: `pnpm-lock.yaml` by hand, generated files (`*.gen.ts`), or another package's internals to fix your package's problem.

---

# PACKAGE FILE: apps/web/AGENTS.md (repeat the pattern per package):

# apps/web: [Customer web app]

## Commands (run from repo root)
```bash
pnpm --filter web dev
pnpm --filter web test [path]
pnpm --filter web typecheck
```

## Stack + rules for THIS package
- [Next.js 16 App Router: server components by default; "use client" only at interactive leaves.]
- [Data fetching in server components via `lib/api`, never fetch() directly in components.]
- [Styling: Tailwind only; design tokens come from @repo/ui, no local color values.]
- UI components: check `@repo/ui` first; build locally only what's app-specific, and flag candidates for promotion to the shared package.

## Boundaries
- May import: `@repo/ui`, `@repo/config`, its own code.
- May NOT import: `apps/api` internals. API access goes through [the client in lib/api / generated types].

How to use

The mechanic that makes this work: agents apply the NEAREST AGENTS.md to the file being edited, package files override the root, so keep the root file thin (map + repo-wide invariants) and put stack specifics in each package. This is how large monorepos do it in practice (OpenAI's own repo nests dozens of these). The format is the open standard read by Codex, Cursor, Copilot, Gemini CLI, and most coding agents; for Claude Code, a root CLAUDE.md containing just '@AGENTS.md' bridges it.

Originated fromStan SedberryUpdated
Configintermediate

More agent prompts

You are a software engineering agent working in the [PRODUCT/TEAM] codebase ([LANGUAGE/STACK]). Your objective is to take an assigned task from description to verified, working code. You may read and modify anything in the repository; you do not push, merge, deploy, or alter CI configuration unless the task explicitly says to.

# Operatin

Coding Agent System Prompt

Autonomous coding agent that matches repo conventions, proves work with passing tests before claiming done, and reports failures truthfully.

Agentintermediate
You are a debugging agent for the [PRODUCT] codebase. Your objective is to find the root cause of a reported bug, fix it with the smallest possible change, and prove the fix. You are not here to refactor, harden, or improve unrelated code: a debugging session that ends in a 40-file diff has failed even if the bug is gone.

# Reproduce Bef

Debugging Agent System Prompt

Root-cause-first debugging agent: no fix until the bug is reproduced, minimal diffs only, and done means the repro dies while the test suite stays green.

Agentintermediate
You are a code migration agent. Your objective is to move the [PRODUCT] codebase from [SOURCE VERSION/FRAMEWORK] to [TARGET VERSION/FRAMEWORK] while preserving behavior exactly. You are a mechanical translator with judgment, not a redesigner: the product must work the same after every step you take.

# The Prime Rule: Migration Changes On

Code Migration Agent System Prompt

Framework-upgrade agent that migrates in build-green slices, verifies every codemod, follows official guides over memory, and never mixes in behavior changes.

Agentadvanced

Search prompts

Find a prompt by title, description, tag, or category.