Rules for AI agents working on the codex-ruby gem (a pure-Ruby SDK for the Codex CLI).
lib/codex_sdk.rb— entry point: defines theCodexSDKmodule, error classes, andrequires every component.lib/codex_sdk/version.rb— single source of truth for the gem version.lib/codex_sdk/client.rb— the publicClient(start_thread,resume_thread).lib/codex_sdk/agent_thread.rb— thread object with blocking (run) and streaming (run_streamed) execution.lib/codex_sdk/exec.rb— subprocess lifecycle management for the Codex CLI.lib/codex_sdk/events.rb/items.rb— typed JSONL event and item classes.lib/codex_sdk/options.rb/config_serializer.rb— thread options and TOML/CLI flag serialization.lib/codex_sdk/rollout_context_snapshot_reader.rb— parses Codex rollout logs fortoken_countdata.spec/— RSpec tests, mirroringlib/codex_sdk/one file per component.codex-ruby.gemspec— gem metadata (note: the gem name iscodex-ruby, the module isCodexSDK).CHANGELOG.md— human-edited changelog.
- Bump the version at the end of every feature or bugfix. Edit
lib/codex_sdk/version.rband add a matching entry toCHANGELOG.mdbefore the work is considered done. This is easy to forget — treat it as part of the definition of done for any change that ships behavior. - Never ship without running the spec suite and the linter. Both
bundle exec rspecandbundle exec rubocopmust be green — CI runs both. - Keep everything under the
CodexSDKnamespace. No top-level constants. Clients, threads, events, items, and errors all live underCodexSDK::. - Don't break downstream apps. This SDK is consumed by other Ruby projects — the public API (
Client,AgentThread,Events::*,Items::*) must stay backwards-compatible within a minor series.
- Follow SemVer.
- Patch (
0.1.2 → 0.1.3): bugfixes, internal refactors, lint/tooling and doc-only changes with no user-visible behavior shift. - Minor (
0.1.2 → 0.2.0): new features, new options, new public APIs (pre-1.0 may also include breaking changes here, but call them out loudly). - Major (
0.1.2 → 1.0.0+): breaking changes in stable releases.
- Patch (
- Every version bump must have a corresponding
## x.y.z (YYYY-MM-DD)section inCHANGELOG.md, matching the existing format, describing the change from a user's perspective. - After a release commit lands on
main, tag itvX.Y.Z(matches the pattern set byv0.1.1,v0.1.2, ...) and push the tag:git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z. Cut a matching GitHub release.
- Understand the request; look for skills/brainstorming if it is non-trivial.
- Write or update specs first when the change is testable — mirror the existing
spec/codex_sdk/*_spec.rblayout. - Implement the change using existing patterns — mirror the style of neighboring files.
- Run
bundle exec rspecandbundle exec rubocop. - Bump the version in
lib/codex_sdk/version.rb. - Add a changelog entry in
CHANGELOG.mddated today, describing the change from a user's perspective. - Commit with a short imperative subject line (see recent
git logfor tone; Conventional Commit prefixes likefix:,feat:,chore:are in use).
- Ruby
>= 3.2(CI tests 3.2, 3.3, 3.4). Avoid syntax or APIs that require newer. - Every Ruby file starts with
# frozen_string_literal: true. - Keep the SDK dependency-free at runtime — it shells out to the Codex CLI and parses JSONL with the stdlib. Do not add runtime dependencies without strong justification.
- Subprocess handling lives in
exec.rb; keep process lifecycle (spawn, stream, graceful shutdown, interrupt) there rather than scattering it. - Redact secrets (API keys) in any
inspect/logging output — see existing redaction patterns. - Follow the repo's RuboCop config (
.rubocop.yml). Let RuboCop autocorrect formatting rather than hand-fighting it.
- RSpec only; no Rails. Tests run against the real
lib/code with the Codex CLI subprocess mocked/stubbed where needed. - Add a focused spec for every new event type, item type, option, or parsing path.
- Both
rspecandrubocoprun in GitHub Actions on every push and PR — keep both green.
- Add a new runtime dependency only when it is genuinely needed, and add it to
codex-ruby.gemspecwith a pessimistic version constraint (~>). - Keep the gem slim — it is meant to be an unobtrusive client library.
- Do not edit
Gemfile.lockby hand; runbundle installinstead. - Do not hand-edit
.gemfiles in the repo root orpkg/. - Do not leave
binding.pry,byebug, orputs-based debugging in committed code. - Do not rename public APIs (
Client,AgentThread,Events::*,Items::*) without a corresponding major/minor bump and a migration note. - Do not re-enable
rubygems_mfa_requiredin the gemspec — it was intentionally removed so releases can be pushed without MFA.
- Specs pass:
bundle exec rspec - Lint passes:
bundle exec rubocop -
lib/codex_sdk/version.rbbumped -
CHANGELOG.mdupdated with today's date and a user-facing summary - No stray debug output, commented-out code, or TODOs introduced
- When a release is cut, the matching
vX.Y.Zgit tag exists and has been pushed, and a GitHub release created