use-cases/agent-friendly-clis.md +144 −0 added
1# Create a CLI Codex can use | Codex use cases
2
3[← All use cases](https://developers.openai.com/codex/use-cases)
4
5Copy page [Export as PDF](https://developers.openai.com/codex/use-cases/agent-friendly-clis/?export=pdf)
6
7Ask Codex to create a composable CLI it can run from any folder, combine with repo scripts, use to download files, and remember through a companion skill.
8
9Intermediate
10
111h
12
13Related links
14
15[Codex skills](https://developers.openai.com/codex/skills) [Create custom skills](https://developers.openai.com/codex/skills/create-skill)
16
17## Best for
18
19- Repeated work where Codex needs to search, read, download from, or safely write to the same service, export, local archive, or repo script.
20- Agent tools that need paged search, exact reads by ID, predictable JSON, downloaded files, local indexes, or draft-before-write commands.
21
22## Skills & Plugins
23
24- [Cli Creator](https://github.com/openai/skills/tree/main/skills/.curated/cli-creator)
25
26 Design the command surface, build the CLI, add setup and auth checks, install the command on PATH, and verify it from another folder.
27- [Skill Creator](https://github.com/openai/skills/tree/main/skills/.system/skill-creator)
28
29 Create the companion skill that teaches later Codex tasks which CLI commands to run first and which write actions require approval.
30
31| Skill | Why use it |
32| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
33| [Cli Creator](https://github.com/openai/skills/tree/main/skills/.curated/cli-creator) | Design the command surface, build the CLI, add setup and auth checks, install the command on PATH, and verify it from another folder. |
34| [Skill Creator](https://github.com/openai/skills/tree/main/skills/.system/skill-creator) | Create the companion skill that teaches later Codex tasks which CLI commands to run first and which write actions require approval. |
35
36## Starter prompt
37
38Use $cli-creator to create a CLI you can use, and use $skill-creator to create the companion skill in this same thread.
39Source to learn from: [docs URL, OpenAPI spec, redacted curl command, existing script path, log folder, CSV or JSON export, SQLite database path, or pasted --help output].
40First job the CLI should support: [download failed CI logs from a build URL, search support tickets and read one by ID, query an admin API, read a local database, or run one step from an existing script].
41Optional write job: [create a draft comment, upload media, retry a failed job, or read-only for now].
42 Command name: [cli-name, or recommend one].
43Before coding, show me the proposed command surface and ask only for missing details that would block the build.
44
45Use $cli-creator to create a CLI you can use, and use $skill-creator to create the companion skill in this same thread.
46Source to learn from: [docs URL, OpenAPI spec, redacted curl command, existing script path, log folder, CSV or JSON export, SQLite database path, or pasted --help output].
47First job the CLI should support: [download failed CI logs from a build URL, search support tickets and read one by ID, query an admin API, read a local database, or run one step from an existing script].
48Optional write job: [create a draft comment, upload media, retry a failed job, or read-only for now].
49 Command name: [cli-name, or recommend one].
50Before coding, show me the proposed command surface and ask only for missing details that would block the build.
51
52## Introduction
53
54When Codex keeps using the same API, log source, exported inbox, local database, or team script, give that work a composable interface: a command it can run from any folder, inspect, narrow, and combine with `git`, `gh`, `rg`, tests, and repo scripts.
55
56Add a companion skill that records when Codex should use the CLI, what to run first, how to keep output small, where downloaded files land, and which write commands need approval.
57
58In this workflow, `$cli-creator` helps Codex build the command. `$skill-creator` helps Codex save a reusable skill such as `$ci-logs`, which future tasks can invoke by name.
59
60## How to use
61
621. [Decide whether the job needs a CLI](#choose-what-the-cli-should-do)
632. [Share the source Codex should learn from](#share-the-docs-files-or-commands)
643. [Run `$cli-creator`](#ask-codex-to-build-the-cli-and-skill)
654. [Test the installed command](#verify-the-command-works-from-any-folder)
665. [Invoke the saved skill later](#use-the-skill-later)
67
68## Choose what the CLI should do
69
70Start with the thing you want Codex to do, not the technology you want it to write. A good CLI turns a repeated read, search, download, export, draft, upload, poll, or safe write into a command Codex can run from any repo.
71
72| Situation | What Codex can do with the CLI |
73| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
74| **CI logs live behind a build page.** | Take a build URL, download failed job logs to `./logs`, and return file paths plus short snippets. |
75| **Support tickets arrive as a weekly export.** | Index the newest CSV or JSON export, search by customer or phrase, and read one ticket by stable ID. |
76| **An API response is too large for context.** | List only the fields it needs, read the full object by ID, and export the complete response to a file. |
77| **A Slack export has long threads.** | Search with `--limit`, read one thread, and return nearby context instead of the whole archive. |
78| **A team script runs four different steps.** | Split setup, discovery, download, draft, upload, poll, and live write into separate commands. |
79| **A plugin finds the record, but Codex needs a file.** | Keep the plugin in the thread; use a CLI to download the attachment, trace, report, video, or log bundle and return the path. |
80
81## Share the docs, files, or commands
82
83Codex needs something concrete to learn from: docs or OpenAPI, a redacted curl command, an export or database path, a log folder, or an existing script. If you want the CLI to follow a familiar style, paste a short `--help` output from `gh`, `kubectl`, or your team's own tool.
84
85If the command needs auth, tell Codex the environment variable name, config file path, or login flow it should support. Set the secret yourself in your shell or config file. Do not paste secrets into the thread. Ask Codex to make the CLI's setup check fail clearly when auth is missing.
86
87## Ask Codex to build the CLI and skill
88
89Use the starter prompt on this page. Fill in the source Codex should learn from and the first job the CLI should support.
90
91Before Codex writes code, it should show the proposed command surface and ask only for missing details that would block the build.
92
93## Verify the command works from any folder
94
95Codex should not stop after `cargo run`, `python path/to/script.py`, or an uninstalled package command. Ask it to test the installed command from another repo or a temporary folder, the way a later task will use it.
96
97**Test the CLI like a future agent**
98
99Test [cli-name] the way you would use it in a future task.
100Please show proof that:
101- command -v [cli-name] succeeds from outside the CLI source folder
102- [cli-name] --help explains the main commands
103- the setup/auth check runs
104- one safe discovery, list, or search command works
105- one exact read command works with an ID from the discovery result
106- any large log, export, trace, or payload writes to a file and returns the path
107- live write commands are not run unless I explicitly approved them
108Then read the companion skill and tell me the shortest prompt I should use when I need this CLI again.
109
110If Codex returns a giant JSON blob, ask it to narrow the default response and add a file export for full payloads. If it forgets the approval boundary, ask it to update the companion skill before you use it in another thread.
111
112## Use the skill later
113
114When you need the CLI again, invoke the skill instead of pasting the docs again:
115
116Use $ci-logs to download the failed logs for this build URL and tell me the first failing step.
117
118Use $support-export to search this week's refund complaints and read the three highest-value tickets.
119
120Use $admin-api to find this user's workspace, read the billing record, and draft a safe account note.
121
122For recurring work, test the skill once in a normal thread, then ask Codex to turn that same invocation into an automation.
123
124## Related use cases
125
126[
127
128### Create browser-based games
129
130Use Codex to turn a game brief into first a well-defined plan, and then a real browser-based...
131
132Engineering Code](https://developers.openai.com/codex/use-cases/browser-games)[
133
134### Save workflows as skills
135
136Turn a working Codex thread, review rules, test commands, release checklists, design...
137
138Engineering Workflow](https://developers.openai.com/codex/use-cases/reusable-codex-skills)[
139
140### Upgrade your API integration
141
142Use Codex to update your existing OpenAI API integration to the latest recommended models...
143
144Evaluation Engineering](https://developers.openai.com/codex/use-cases/api-integration-migrations)