This file defines repository-specific operating rules for coding agents working in codex-gateway. Prefer existing project patterns over invention.
- Language: Go (
1.26+) - CLI framework:
cobra - HTTP stack:
net/http - Config format: YAML (
gopkg.in/yaml.v3) - Testing:
go test+httptest
- README.md
- README.zh-CN.md
- docs/en/README.md
- docs/zh-CN/README.md
- docs/en/architecture.md
- docs/zh-CN/architecture.md
- docs/en/oauth-setup.md
- docs/zh-CN/oauth-setup.md
- docs/en/privacy-boundary.md
- docs/zh-CN/privacy-boundary.md
- docs/en/git-flow.md
- docs/zh-CN/git-flow.md
- .opencode/skills/code-standard/SKILL.md
- .opencode/skills/doc-maintainer/SKILL.md
- .opencode/skills/git-workflow/SKILL.md
go mod downloadgo test ./...
go test -race ./...
go build ./cmd/codex-gatewaygo test ./internal/server -run TestProxy -v
go test ./internal/oauth -run TestClient_AuthenticateSuccess -v
go test ./internal/auth -run TestManager -vMaintain one-way dependency flow:
config/oauth/auth -> upstream -> server -> cli
Rules:
- Keep transport logic in
internal/serverandinternal/upstream. - Keep token lifecycle logic in
internal/authand OAuth protocol logic ininternal/oauth. - Keep
internal/clithin (wiring and process orchestration only). - Avoid hidden globals; pass dependencies explicitly.
- Use module-rooted imports (
codex-gateway/internal/...). - Keep package responsibilities focused.
- Avoid import-time side effects.
- Use
gofmtfor all Go source files. - Add comments only when logic is non-obvious.
- Keep production code and comments in English.
- Prefer explicit struct contracts at package boundaries.
- Return actionable errors with context (
fmt.Errorf("...: %w", err)). - Never silently swallow errors.
- Prefer TDD for feature and bugfix work.
- Keep tests near package behavior (
*_test.goin same package directory). - Cover happy paths and edge/failure paths.
- Run targeted tests first, then full suite for substantial changes.
- If behavior changes, update README.md, README.zh-CN.md, and relevant docs under docs/.
- Keep architecture and privacy claims aligned with implementation.
- Do not document features as complete before tests pass.
- Branches:
main,dev, andfeat/*orfeature/*. - Commit style: Angular conventional commits (
feat:,fix:,docs:,chore:). - Merge feature branches into
devfirst; mergedevtomainfor release.
- Changes follow architecture and style constraints.
- Relevant targeted tests were run.
- Full test suite was run for substantial changes.
- User-facing docs were updated for behavior changes.
- No conflict with .opencode/skills/ rules.