Skip to content
LinkedInX

Building a Codex Harness - Overview of Settings, Rules, and Skills

About 5 minutes

Target audience: Developers who understand basic Codex operation and want to design safe, repeatable development workflows for personal or team repositories
Prerequisites:
  • Access to the Codex CLI, IDE extension, or Codex app
  • Basic knowledge of Git and repository structure

Reliable Codex work requires more than repeating a long prompt in every thread. Repository rules, permissions, reusable procedures, and verification steps need versioned ownership. A Codex harness combines what Codex reads before work, what capabilities it can invoke, and what checks must pass after work.

The Codex Levels framework defines this area as Level 6: Harness Builder. For a practice-first route, build a minimal version in Level 6 Practice and then return here to design each component in detail.

A practical harness has three layers.

project-root/
├── AGENTS.md              # Entry point and working contract
├── shared/                # Shared rules, skills, and workflows
├── .agents/skills/        # Repository skills discovered by Codex
└── .codex/                # Codex-specific configuration and adapters
    ├── config.toml
    ├── rules/
    ├── hooks.json
    └── agents/

AGENTS.md defines the working agreement. shared/ owns detailed procedures that can be shared across runtimes. .codex/ and .agents/ expose Codex-specific configuration and capabilities. Required guidance belongs in Git; credentials and generated local state do not.

OrderPageFocus
1AGENTS.md hierarchy designGlobal, project, and subdirectory instruction chains
2config.toml designModels, approvals, sandboxes, and profiles
3Rules file designAllow, prompt, or forbid commands outside the sandbox
4Commands and WorkflowsInteractive commands, prompt files, and non-interactive execution
5Skills design patternsSKILL.md and progressive disclosure
6Subagents designSpecialized roles and parallel work
7Hooks implementationDeterministic lifecycle automation
8MCP and Plugins integrationExternal tools, apps, and MCP servers
9Memories designLocal recall separated from mandatory rules
10Harness testing and validationDrift detection and CI validation
11Plugin Marketplace publishingPackaging and distributing reusable capabilities
  1. Keep mandatory rules in AGENTS.md or checked-in documentation, not only in memory.
  2. Grant the narrowest filesystem and network permissions that complete the task.
  3. Separate explanatory guidance from enforceable Rules, Hooks, and CI checks.
  4. Keep shared policy in shared/ and treat .codex/ as the Codex adapter layer.
  5. Validate harness changes for syntax, references, synchronization, and behavior.

This repository is a working example: AGENTS.md routes Codex to shared/rules/, while .codex/agents/ is generated from shared/agents/. Start with AGENTS.md hierarchy design.

See the references for the external specifications and background sources used on this page.[1][2]

  1. OpenAI, Codex documentation
  2. OpenAI, OpenAI API documentation