$git clone https://github.com/Austin1serb/agents-mdPractical AGENTS.md and Codex prompt patterns for coding agents that need better context discipline, safer command output, and lower token usage.
| 1 | # AGENTS.md Patterns for Context Engineering in Coding Agents |
| 2 | |
| 3 | Practical `AGENTS.md` and Codex prompt patterns for coding agents that need better context discipline, safer command output, and lower token usage. |
| 4 | |
| 5 | This repo is for Software Engineers using Codex, Claude Code, Cursor, Windsurf, GitHub Copilot, or custom AI coding agents who want agents to get the most from their agent harness. |
| 6 | |
| 7 | > [!NOTE] |
| 8 | > There will be more to come. Follow or watch to get updates. |
| 9 | |
| 10 | ## What's In This Repo: |
| 11 | |
| 12 | | Resource | Purpose | |
| 13 | |---|---| |
| 14 | | [AGENTS.md instructions for coding agents](./AGENTS.md) | Optimized coding-agent instructions for context discipline, and better responses. | |
| 15 | | [Coding-optimized system prompt](./codex-optimized-prompt.md) | A practical Codex prompt more focued on coding. | |
| 16 | | [How to change Codex system prompt](./change-codex-system-prompt.md) | Instructions for replacing Codex system prompt, including subagent instruction files. | |
| 17 | | [OpenAI Codex GPT-5.5 base system prompt](./codex-GPT-5.5-system-prompt.md) | OpenAI's base Codex GPT-5.5 system prompt, which is more general-purpose than the coding-optimized prompt. | |
| 18 | |
| 19 | ## Biggest Current Win: Byte-capped command output |
| 20 | |
| 21 | A common coding-agent failure mode is pulling thousands of irrelevant lines into context while researching a task. |
| 22 | |
| 23 | Line limits like `head -n 20`, help sometimes, but they are not safe. One huge line can still flood the context window, reducing the output quality and increasing token usage. |
| 24 | |
| 25 | Use byte caps for unknown or potentially large command output: |
| 26 | |
| 27 | ```bash |
| 28 | COMMAND 2>&1 | head -c 4000 |
| 29 | ``` |
| 30 | |
| 31 | For logs, test failures, or recent output: |
| 32 | |
| 33 | ```bash |
| 34 | COMMAND 2>&1 | tail -c 4000 |
| 35 | ``` |
| 36 | |
| 37 | see: [AGENTS.md](https://github.com/Austin1serb/agents-md/blob/main/AGENTS.md#command-output) - Command Output |
| 38 | |
| 39 | In my own Codex workflows, this single `AGENTS.md` rule reduced average token usage by roughly 50% across comparable tasks. |
| 40 | |
| 41 | ## Why Context Discipline Matters |
| 42 | |
| 43 | Coding agents are great at writing shell commands, but often consume much more information than necessary to complete a task. For example, you might have a file that contains many utility functions, you might ask the agent to find a specific function and explain it. The agent might read the entire file, when it only needed to read a few lines to find the function definition. This can lead to degraded responses, higher token usage, and more irrelevant information in context. |
| 44 | |
| 45 | ## How to Use AGENTS.md |
| 46 | |
| 47 | Copy [`AGENTS.md`](./AGENTS.md) into the root of any repo that supports agent instruction files. To use in all repos, add it to the root of `/.codex` |
| 48 | |
| 49 | For Codex, this repo also includes [`codex-optimized-prompt.md`](./codex-optimized-prompt.md), which I use as a coding-optimized system prompt. |
| 50 | |
| 51 | To use it as your default Codex instruction file, download the file, and add this to your `.codex/config.toml`: |
| 52 | |
| 53 | ```toml |
| 54 | model_instructions_file = "path/to/codex-optimized-prompt.md" |
| 55 | ``` |
| 56 | |
| 57 | You can also set different instruction files for different Codex profiles or subagents. |
| 58 | |
| 59 | Maintained by [Austin Serb @ Serbyte Web Design](https://www.serbyte.net/). |