ホーム / Skills / 開発効率化 / Writing for Agents エージェント向け文書
開発効率化

Writing for Agents エージェント向け文書

Matt PocockMITSkill の言語: 英語
ライセンス確認済みスクリプトなし
デモ実行記録 · claude-opus-5-5 · 2026年10月
Can you improve this CLAUDE.md for our repo? Agents keep ignoring parts of it. ```markdown # Project Guidelines This is a Next.js 15 app using the App Router with TypeScript. We use pnpm as our package manager. The scripts are in package.json. ## Important Rules - Please always make sure to be very careful and thorough when making changes. - Don't use npm or yarn. Don't use npm or yarn under any circumstances, always use pnpm. - Never ever use the `any` type. - Run `pnpm lint` and `pnpm test` before you finish. - Don't put business logic in React components. - Make sure you write good code that follows best practices. ## Database We use Prisma with PostgreSQL. The schema is at prisma/schema.prisma. When you change the schema you need to run `pnpm prisma migrate dev --name <name>` and you also need to run `pnpm prisma generate` afterwards, otherwise the types will be out of date and things won't compile. Don't forget to run prisma generate!! ## Testing We use Vitest. Tests live next to the code in `*.test.ts` files. Run `pnpm test`. Please don't forget to run tests before finishing. ## Style Use Tailwind for styling. Don't write CSS files. Don't use inline styles. Don't use styled-components. ```
Skill: writing-for-agents

The main problem is that the important rules are hard to spot among filler. Here's a rewrite:

# Project Guidelines

Next.js 15 (App Router) + TypeScript, managed with **pnpm**. Scripts are in `package.json`.

## Rules

- Run every package and script command through `pnpm` (`pnpm add`, `pnpm dlx`, `pnpm <script>`). The lockfile is `pnpm-lock.yaml`, and running another package manager corrupts it.
- Use precise types everywhere. For data whose shape you don't know yet, use `unknown` and narrow it with type guards or a schema. Never use `any`.
- Keep React components presentational. Put business logic in <!-- TODO: e.g. `src/lib/` or `src/server/` --> and call it from the component.
- Style with Tailwind utility classes only.

## Database (Prisma + PostgreSQL)

After any edit to `prisma/schema.prisma`, run both commands, in this order:

1. `pnpm prisma migrate dev --name <descriptive_name>`
2. `pnpm prisma generate`

If you skip step 2, the generated types go stale and the build fails in ways that are hard to trace back.

## Testing

Vitest. Put each test next to its source file as `<name>.test.ts`.

## Done means

You're finished only when both commands pass with zero errors on your final change:

- `pnpm lint`
- `pnpm test`

What I changed and why:

  1. Cut lines that don't change behavior. "Be careful and thorough" and "write good code that follows best practices" are things the agent already tries to do. They make the file longer and draw attention away from the rules that matter.
  2. Gave each rule one home. "Run tests" appeared twice and "use pnpm" was said twice in one bullet. When an instruction is repeated, it's hard to tell how important it is compared with the rest. Lint and test now live in a single Done means section at the end, where the agent checks whether it's finished.
  3. Said what to do, not just what to avoid. Rules like "Don't use npm or yarn", "Never use any", and "Don't write CSS / inline / styled-components" put the banned thing front and center. Each rule now names what to use instead (pnpm, unknown + narrowing, Tailwind classes). I kept "Never use any" as a hard limit, paired with the alternative.
  4. Added the reasons agents can't figure out on their own. The lockfile damage and the stale Prisma types are why those rules exist. A rule that comes with its reason is less likely to be dropped as optional.
  5. Turned the Prisma steps into a numbered list instead of a paragraph ending in "Don't forget!!".
  6. Made "finished" checkable. "Run lint and test" became "both pass with zero errors". Before, an agent could run the tests, see failures, and still stop.

One thing for you to fill in: "Don't put business logic in components" probably gets ignored because the agent doesn't know where that logic should go. Replace the TODO with your real directory, such as src/lib/ or server actions in app/**/actions.ts.

Optional: if agents still use npm or skip lint, put it in a hook instead of the doc. A PreToolUse hook can block npm/yarn commands, and a Stop hook can run pnpm lint && pnpm test. I can set either one up with /update-config if you want.

Real run recorded with claude-code / claude-opus-5-5. Output is shown verbatim, unmodified.

できること

エージェントが読むあらゆる文書の書き方ガイドです。前提は、同じいくつかのてこを使えば skill も CLAUDE.md もリンク先の文書も予測しやすくなる、なぜならエージェントは毎回同じ手順をたどるべきだから、というものです。

仕組み

  1. コンテキストポインター: skill の description や AGENTS.md の 1 行の言葉遣いが、その先の内容にいつ、どれだけ確実にたどり着くかを決めます。
  2. 2 つのコスト: 追加するたびに、コンテキスト(常に読み込まれる文章)か、人の注意(どの文書があるかを覚えること)のどちらかを消費します。
  3. 情報の階層: 手順は本文に、参考資料はポインターの先に置き、文書の肥大化を避けます。
  4. 完了条件: 各手順を確認できる条件で終わらせ、エージェントが早く切り上げないようにします。
  5. 刈り込み: 意味ごとに情報源は 1 か所、モデルがもともと守る文は削り、「やってはいけないこと」より「やるべきこと」を書きます。
  6. もう 1 つのファイルは skill 固有の選択を扱います。frontmatter、ユーザー専用とモデル起動可能の違い、ルーター skill。

向いている場面

skill、CLAUDE.md、AGENTS.md を書く、または引き締めるとき。

知っておきたいこと

私たちの試用では、サンプルの CLAUDE.md を書き直し、変更点を 1 つずつ説明し、ディレクトリ名をでっち上げずに TODO を残しました。

補足とリスク

指示だけのファイルで、スクリプトはなく、ネットワーク接続も行いません。 ファイルの編集を頼んだ場合、エージェントはプロジェクト内のそのファイルに書き込むことがあります。 パッケージには元リポジトリの MIT ライセンス(LICENSE)と agents/openai.yaml(Codex 用の表示名)も含まれます。