Page
1
D aniel Vaughan Agentic Coding with Build intelligent agent workfl ows using Agentic Engineering, MCP, hooks, and delivery automation Daniel Vaughan THINGS YOU WILL LEARN • Set up, authenticate, and prompt Codex CLI eff ectively • Write AGENTS.md rules and apply patt erns that avoid common pitfalls • Choose approval modes, kernel-level sandboxing, and trust boundaries • Manage model selection, reasoning eff ort, context windows, and cost • Extend the agent with MCP servers, hooks, and skills • Coordinate sub-agents, multi-agent orchestration, and worktrees • Integrate Codex into CI/CD, security hardening, and enterprise deployment • Apply Codex to code review, migration, backend, frontend, and infrastructure as code Agentic Coding with OpenAI Codex CLI is a comprehensive guide to agentic AI development with OpenAI’s command-line coding agent. Across six parts, you’ll move from fi rst principles to production workfl ows and team-scale practice: prompting and AGENTS.md confi guration, approval modes and kernel-level sandboxing, model selection, context and cost management, MCP servers, hooks, skills, sub-agents and orchestration, worktrees, CI/CD integration, security hardening, and enterprise deployment. Later chapters cover debugging and testing agentic workfl ows, AI code review, practical engineering guides (codebase migration, backend, frontend, and infrastructure as code), and the bigger picture: benchmarks, competing tools, harness engineering, and how to structure an agentic engineering team. Whether you’re a solo developer looking to multiply your output or an engineering lead rolling out agentic workfl ows across a team, this book gives you the mental models and practical techniques to work eff ectively with AI coding agents. It draws on real-world experience and community insights, and every chapter includes learning objectives, worked examples, and hands-on exercises. www.packtpub.com Agentic Coding with OpenAI Codex CLI A gentic Coding w ith O penA I C odddddeeexxxx CCCCCC LLI
Page
2
Agentic Coding with OpenAI Codex CLI Build intelligent agent workflows using Agentic Engineering, MCP, hooks, and delivery automation Daniel Vaughan
Page
3
Agentic Coding with OpenAI Codex CLI Copyright Daniel Vaughan, 2026. All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of the author, except in the case of brief quotations embodied in reviews and certain other non-commercial uses permitted by copyright law. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, the author shall not have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this book. Codex CLI is an open-source project by OpenAI, released under the Apache 2.0 licence. This book is an independent publication and is not affiliated with, endorsed by, or sponsored by OpenAI. All trademarks and registered trademarks appearing in this book are the property of their respective owners. First edition Production reference: 1290726 ISBN: 978-1-80834-889-1
Page
4
Contributors About the author Daniel Vaughan is a technology leader and software architect based in the United Kingdom, specialising in agentic AI. He has spent nearly thirty years across enterprise, startup, and aca- demic settings, with a career-long focus on engineering quality and developer productivity. His work now centres on the shift in which AI stops being an experiment and becomes core to how organisations build software. Daniel is Head of Forward Deployed Engineering at HCLTech AI Labs, where he leads a global practice embedding engineers and coding agents inside complex enterprise environments to take production AI from prototype to live systems. He built the practice from the ground up, running lean regional pods in which a shared architect, a small number of engineers, and a team of agents working through tools such as Codex, Claude Code, Cursor, and GitHub Copilot deliver the output of a much larger team. Before HCLTech AI Labs, Daniel was director of software engineering at Mastercard in London, leading cloud strategy and architecture for real-time payment products in a highly regulated finan- cial services environment. Earlier, he spent eight years at the European Bioinformatics Institute in Cambridge, moving from software engineer into engineering leadership, working on the same problems of software quality and developer productivity that he now solves with agentic tooling. He is the author of Cloud Native Development with Google Cloud (O’Reilly, 2024) and Ext GWT 2.0: Beginner’s Guide (Packt, 2010), a Google Developer Expert, and a Green Software Champion. He writes about agentic engineering and AI-assisted development at blog.danielvaughan.com. This book was written with the assistance of AI coding agents, a fact the author considers appro- priate given the subject matter. The editorial judgements, architectural decisions, and opinions expressed are entirely human.
Page
5
(This page has no text content)
Page
6
(This page has no text content)
Page
7
(This page has no text content)
Page
8
(This page has no text content)
Page
9
(This page has no text content)
Page
10
(This page has no text content)
Page
11
(This page has no text content)
Page
12
(This page has no text content)
Page
13
(This page has no text content)
Page
14
(This page has no text content)
Page
15
Table of Contentsxiv The three-tier loading model • 165 Writing the description field • 165 The agents/openai.yaml file: policy and MCP dependencies • 166 Building and publishing a skill • 167 Sizing the skill: the five-tier spectrum • 168 Authoring workflow: build manually, then encode • 169 Evaluating skills • 170 Plugins: Packaging and Distribution 172 Plugin architecture • 173 Marketplace discovery and distribution • 174 Installation policies and enterprise governance • 174 Install and remove lifecycle via app-server RPC • 176 Reusable workflow patterns: composing skills and plugins • 177 Plugin-bundled hooks • 178 Extension-first architecture • 178 Case studies 178 Nx monorepo agent skills • 178 codex-pr-body: the first official OpenAI team-authored project skill • 179 aigorahub/elves: a meta-skill that orchestrates workflows • 180 Google Agent Skills: platform-maintained knowledge packages • 181 Summary 181 Exercises 183 Chapter 11: Sub-Agents and Parallel Execution 185 Learning Objectives 185 The Sub-Agent Model 186 Built-in agents • 186 Switching between threads • 186 Custom agent definitions • 187 Picking a model for a sub-agent • 189 Session-wide limits • 189
Page
16
(This page has no text content)
Page
17
(This page has no text content)
Page
18
(This page has no text content)
Page
19
(This page has no text content)
Page
20
(This page has no text content)