Generate a Precise AGENTS.md Routing Map for Codex

Create an AGENTS.md configuration that restricts Codex test execution to specific workspace directories, preventing inefficient repo-wide test runs.

Agent prompt for ChatGPT

Prompt

Prompt
You are a Senior Infrastructure Engineer. Your job is to generate an AGENTS.md file for a monorepo that routes Codex task execution to specific sub-package test commands. 1. Map every subdirectory in the root to a specific test command prefix. 2. Use a YAML-based structure for the routing table. 3. Include a priority field for each route. 4. Explicitly state that Codex must only trigger tests within the path of the modified files. 5. Do not invent external dependencies or CI tools. Please ask the following 3 questions first and wait for my reply: 1. What are the primary sub-directories in your monorepo? 2. What is the test command for each directory? 3. Do you have any shared utility libraries that require cross-package testing? This is technical configuration for repository automation.

Example output

Package-to-test command routingEach package runs only its own tests, never repo-wide
ItemCommandPriority
packages/authnpm run test:auth1
packages/apinpm run test:api1
packages/uijest --projects packages/ui2

Example for: a TypeScript monorepo with packages/auth, packages/api, and packages/ui.

AGENTS.md

Task Execution Routing

This configuration restricts Codex to local execution contexts to optimize performance and prevent unnecessary global test cycles.


routes:

  • path: packages/auth
    command: npm run test:auth
    priority: 1
    scope: local
  • path: packages/api
    command: npm run test:api
    priority: 1
    scope: local
  • path: packages/ui
    command: jest --projects packages/ui
    priority: 2
    scope: local

Execution Logic

  1. Codex must detect the file path of the current change set.
  2. Codex must cross-reference the change path against the routes table.
  3. Codex must execute the specific command mapped to the directory.
  4. If a file is changed in a shared directory that is not mapped, Codex must default to a dry-run log and request human verification before initiating a full suite test.

Constraints

  • Do not run npm test at the root level.
  • Do not attempt to resolve dependencies outside of the affected package scope unless explicitly instructed.
  • Maintain logs of all execution paths in .logs/agent_runs.json.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces path-scoped execution to prevent slow repo-wide test runs.
  • Uses a structured YAML format that is easy for agents to parse.
  • Includes a priority system to handle critical packages first.

Use this prompt when working with Codex or ChatGPT to configure agent behavior in a monorepo. Have your directory structure and test scripts ready. Paste the prompt, answer the three questions, and receive the formatted AGENTS.md content.

Common edits

  • Adjust the priority levels if certain packages are more critical.
  • Add new routes if you add more sub-directories to the monorepo.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

More in Codex

Draft Security Guardrails for AGENTS.md Configuration

Generate a robust security policy for AGENTS.md to restrict dangerous shell operations, credential access, and destructive commands in automated environments.

AI Coding AgentsClaude Code

Generate Reproducible Bug Fix Specs for Coding Agents

Get a standalone reproduction test script and a precise technical plan to fix a bug, ensuring your AI agent stays focused and avoids unnecessary file changes.

AI Coding AgentsClaude Code

Create Automated Verification Loops for Long-Running Coding Agents

Generate a deterministic shell pipeline that combines linting, isolated unit testing, and diff-budget monitoring to validate AI agent code changes.

Create Selective Pre-Commit Hooks for Claude Code

This prompt generates a bash script that triggers specific tests and typechecks only for packages modified in your current git branch.

AI Coding AgentsClaude Code

Design a Sandbox Security Policy for Autonomous Coding Agents

Generate a rigorous security policy for autonomous agents to define allowed shell commands, file access boundaries, and network restrictions.