Build an AGENTS.md Routing Map for Monorepo Codex Tests

Generates a path-scoped test execution matrix inside AGENTS.md that forces Codex to run checks only within touched sub-packages instead of the entire repo.

Skill prompt for ChatGPT

Prompt

Installs to .agents/skills/build-an-agents-md-routing-map-for-monorepo-codex-tests/

mkdir -p .agents/skills/build-an-agents-md-routing-map-for-monorepo-codex-tests && curl -sL "https://prompts-gpt.com/prompts/build-an-agents-md-routing-map-for-monorepo-codex-tests/raw" -o .agents/skills/build-an-agents-md-routing-map-for-monorepo-codex-tests/SKILL.md
SKILL.md
Preview
---
name: build-an-agents-md-routing-map-for-monorepo-codex-tests
description: "Generates a path-scoped test execution matrix inside AGENTS.md that forces Codex to run checks only within touched sub-packages instead of the entire repo."
---

# Build an AGENTS.md Routing Map for Monorepo Codex Tests

Generates a path-scoped test execution matrix inside AGENTS.md that forces Codex to run checks only within touched sub-packages instead of the entire repo.

## Prompt

```
Act as a build infrastructure engineer configuring autonomous coding agents. Your job is to create a path-scoped test execution section for an AGENTS.md file in a monorepo, ensuring Codex runs tests only in affected workspace packages.

Ask me these 3 numbered questions and wait for my reply before drafting:
1. What workspace manager or monorepo tool does the repository use (such as pnpm, Turborepo, Nx, or Cargo)?
2. What are the key package paths and their matching unit or integration test commands?
3. Are there root-level checks that must run only when shared config files change?

Rules:
- Output a pure Markdown section ready to paste directly into AGENTS.md.
- Format package rules into a clean Markdown table with three columns: Package Path, Target Trigger, and Required Test Command.
- Define clear path boundaries so the agent never runs full root test suites when editing a single sub-package.
- Explicitly state exact fallback behavior if a pull request or task edits multiple packages.

Output format:
### Workspace Routing Matrix (table)
### Execution Protocol for Codex (numbered steps with exact CLI commands)
### Safety Boundaries and Non-Goals (bullet list)
```

## Usage Notes

Use this prompt in ChatGPT to draft targeted instructions for Codex CLI. Have your workspace package paths and exact package-level test scripts ready to paste.

Example output

Scoped test command per changed pathCodex runs only the matched package checks, not the whole repo
ItemChanged pathRequired test command
apps/apiapps/api/**@repo/api test:unit
apps/webapps/web/**@repo/web test:unit
packages/uipackages/ui/**@repo/ui test + @repo/web test:unit
packages/dbpackages/db/**@repo/db test:migrate + @repo/api test:unit
Root configsturbo.json, package.jsonpnpm turbo run test

Example for: a Turborepo TypeScript monorepo with an API service, a web frontend, and shared UI/database packages.

Workspace Routing Matrix
Package PathTarget TriggerRequired Test Command
apps/apiAny file modified under apps/api/**pnpm --filter @repo/api test:unit
apps/webAny file modified under apps/web/**pnpm --filter @repo/web test:unit
packages/uiAny file modified under packages/ui/**pnpm --filter @repo/ui test && pnpm --filter @repo/web test:unit
packages/dbAny file modified under packages/db/**pnpm --filter @repo/db test:migrate && pnpm --filter @repo/api test:unit
turbo.json, package.jsonModifications to root configspnpm turbo run test
Execution Protocol for Codex
  1. Inspect changed file paths using git status --porcelain before running any verification scripts.
  2. Match all changed paths against the Package Path column in the routing matrix.
  3. Execute only the scoped commands for matched packages directly from the repository root.
  4. If changes span both apps/api and apps/web without touching shared packages, run their respective commands sequentially: pnpm --filter @repo/api test:unit followed by pnpm --filter @repo/web test:unit.
  5. Only execute root pnpm turbo run test if turbo.json, root package.json, or root pnpm-lock.yaml were directly modified.
Safety Boundaries and Non-Goals
  • Do not run end-to-end Playwright tests unless the task instructions explicitly request full system integration validation.
  • Never execute broad global commands like pnpm test or npm test for isolated component edits in packages/ui.
  • Stop execution immediately if a package-specific command fails; do not attempt automated fixes outside the failing directory.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Constrains Codex agent execution to modified folders, cutting test runtimes and preventing irrelevant test failures.
  • The 3-question intake captures specific workspace structures without requiring pre-edited prompt placeholders.
  • Provides explicit fallback and multi-package execution rules so the agent handles complex commits predictably.

Use this prompt in ChatGPT to draft targeted instructions for Codex CLI. Have your workspace package paths and exact package-level test scripts ready to paste.

Common edits

  • Change the test commands to include typecheck or lint scripts alongside unit test invocations.
  • Add a designated end-to-end test row for changes touching global API routing contracts.

Reuse it: Use in a workflowAdapt in the builder

More in Codex
AI Coding AgentsClaude Code

Convert User Stories into Strict Acceptance Test Assertions

This prompt transforms vague business requirements into precise Given-When-Then test assertions with exact HTTP status codes and JSON payload structures for AI coding agents.

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.

Create a Deterministic Code Review System Prompt for Cursor

Generates a strict, rule-based system prompt for Cursor that rejects subjective nitpicks and only reports verified regressions and broken contracts.

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.