Skip to content
Back to search

spartan-marketplace

MarketplaceWorks with Claude CodeGitHub

Spartan AI Toolkit — engineering discipline layer for Claude Code

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/c0x12c/ai-toolkit with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/c0x12c/ai-toolkit'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/c0x12c--ai-toolkit/badge.svg)](/listings/c0x12c--ai-toolkit)

HTML

<a href="/listings/c0x12c--ai-toolkit"><img src="/api/listings/c0x12c--ai-toolkit/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

# 1. Install (30 seconds, interactive menu)
npx @c0x12c/ai-toolkit@latest --local

# 2. Set up rules for your stack
/spartan:init-rules

# 3. Build something
/spartan:build "add user authentication"

That's it. The `/spartan:build` command handles the full pipeline:

spec → design (if UI) → plan → TDD → code review → PR
  |         |              |      |         |          |
Gate 1   Design Gate    Gate 2  Gate 3   Gate 3.5   Gate 4

Nothing ships without passing every gate.

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 16 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
  3. "name": "spartan-marketplace",
  4. "description": "Spartan AI Toolkit — engineering discipline layer for Claude Code",
  5. "owner": {
  6. "name": "Spartan Stratos"
  7. },
  8. "plugins": [
  9. {
  10. "name": "ai-toolkit",
  11. "description": "Engineering discipline layer for Claude Code — workflows, rules, skills, agents organized in modular packs",
  12. "source": "./toolkit",
  13. "version": "1.27.0"
  14. }
  15. ]
  16. }
README.md · README · 491 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. <p align="center">
  2. <h1 align="center">Spartan AI Toolkit</h1>
  3. <p align="center">
  4. <strong>Stop AI coding agents from shipping sloppy code.</strong>
  5. <br />
  6. Structured workflows &middot; Configurable rules &middot; Quality gates &middot; Any stack
  7. </p>
  8. <p align="center">
  9. <a href="https://www.npmjs.com/package/@c0x12c/ai-toolkit"><img src="https://img.shields.io/npm/v/@c0x12c/ai-toolkit.svg" alt="npm version"></a>
  10. <a href="https://www.npmjs.com/package/@c0x12c/ai-toolkit"><img src="https://img.shields.io/npm/dm/@c0x12c/ai-toolkit.svg" alt="npm downloads"></a>
  11. <a href="https://github.com/c0x12c/ai-toolkit/stargazers"><img src="https://img.shields.io/github/stars/c0x12c/ai-toolkit.svg" alt="GitHub stars"></a>
  12. <a href="https://github.com/c0x12c/ai-toolkit/blob/main/LICENSE"><img src="https://img.shields.io/github/license/c0x12c/ai-toolkit.svg" alt="license"></a>
  13. </p>
  14. </p>
  15. ---
  16. AI coding agents are fast. They're also careless. They skip tests, ignore your coding standards, push without review, and forget everything between sessions.
  17. **Spartan fixes that.** One command runs a full engineering workflow &mdash; spec, plan, TDD, code review, PR &mdash; with quality gates between each step. Your rules, your standards, enforced every time.
  18. ```bash
  19. npx @c0x12c/ai-toolkit@latest --local
  20. ```
  21. Works with **Claude Code**, **Codex**, **Cursor**, **Windsurf**, and **Copilot**. Rules are plain markdown &mdash; works with any AI tool.
  22. ---
  23. ## Before & After
  24. | Without Spartan | With Spartan |
  25. |----------------|-------------|
  26. | "Build this feature" &rarr; jumps straight to code, no plan, no tests, pushes broken code | `/spartan:build` &rarr; writes spec, plans tasks, TDD for each, code review, then PR |
  27. | "Fix this bug" &rarr; guesses a fix, no repro, no test, hopes for the best | `/spartan:debug` &rarr; reproduces first, finds root cause, writes test, then fixes |
  28. | 5 devs on the team &rarr; AI writes different code style for each person | Configurable rules &rarr; same standards for everyone, checked automatically |
  29. | 3-week feature &rarr; AI forgets all context between sessions | Agent memory layer &rarr; carries decisions across sessions |
  30. | Code review catches AI slop &rarr; back-and-forth for days | Quality gates &rarr; review happens before PR, not after |
  31. ---
  32. ## Quick Start
  33. ```bash
  34. # 1. Install (30 seconds, interactive menu)
  35. npx @c0x12c/ai-toolkit@latest --local
  36. # 2. Set up rules for your stack
  37. /spartan:init-rules
  38. # 3. Build something
  39. /spartan:build "add user authentication"
  40. ```
  41. That's it. The `/spartan:build` command handles the full pipeline:
  42. ```
  43. spec → design (if UI) → plan → TDD → code review → PR
  44. | | | | | |
  45. Gate 1 Design Gate Gate 2 Gate 3 Gate 3.5 Gate 4
  46. ```
  47. Nothing ships without passing every gate.
  48. ---
  49. ## What's Inside
  50. | What | Count | Description |
  51. |------|-------|-------------|
  52. | **Slash commands** | 73 | End-to-end workflows, not just prompts |
  53. | **Coding rules** | 28 | Your standards, enforced automatically |
  54. | **Skills** | 34 | Domain knowledge (Kotlin, React, Python, DB, security, etc.) |
  55. | **Agents** | 10 | Specialized reviewers, researchers, planners |
  56. | **Stack profiles** | 8 | Pre-built configs for Go, Python, Java, Kotlin, React, etc. |
  57. | **Quality gates** | 5 | Automated checkpoints between every step |
  58. | **Agent memory** | 3 layers | Index &rarr; topics &rarr; transcripts (grep-only archive) |
  59. ---
  60. ## 5 Workflow Leaders
  61. Each leader runs a full pipeline. One command &mdash; it handles the rest.
  62. | Leader | Command | What happens |
  63. |--------|---------|-------------|
  64. | **Build** | `/spartan:build "feature"` | spec &rarr; design &rarr; plan &rarr; TDD &rarr; review &rarr; PR |
  65. | **Debug** | `/spartan:debug "symptom"` | reproduce &rarr; root cause &rarr; test-first fix &rarr; PR |
  66. | **Startup** | `/spartan:startup "idea"` | brainstorm &rarr; validate &rarr; research &rarr; pitch |
  67. | **Onboard** | `/spartan:onboard` | scan codebase &rarr; map architecture &rarr; save to memory |
  68. | **Research** | `/spartan:research "topic"` | frame question &rarr; gather sources &rarr; analyze &rarr; report |
  69. Or just type `/spartan` &mdash; the smart router figures out what you need.
  70. ---
  71. ## Works With Any Stack
  72. Pick a built-in profile or write your own rules in markdown:
  73. | Profile | Stack | Rules included |
  74. |---------|-------|---------------|
  75. | `kotlin-micronaut` | Kotlin + Micronaut | 8 backend + 3 database rules |
  76. | `react-nextjs` | React + Next.js | Frontend conventions |
  77. | `go-standard` | Go | Error handling, interfaces, concurrency, project layout |
  78. | `python-django` | Python + Django | Models, views, ORM, testing |
  79. | `python-fastapi` | Python + FastAPI | Endpoints, Pydantic, async patterns |
  80. | `java-spring` | Java + Spring Boot | Controllers, services, JPA, security |
  81. | `typescript-node` | TypeScript + Node.js | Express/Fastify, Zod, strict mode |
  82. | `custom` | Anything | Blank template &mdash; bring your own rules |
  83. Not on this list? Create rules in markdown, point the config at them. The toolkit reads whatever you give it.
  84. ```yaml
  85. # .spartan/config.yaml — you control everything
  86. stack: go-standard
  87. architecture: clean
  88. rules:
  89. backend:
  90. - rules/go/ERROR_HANDLING.md
  91. - rules/go/INTERFACES.md
  92. - rules/custom/OUR_AUTH_RULES.md
  93. commands:
  94. test:
  95. backend: "go test ./..."
  96. lint:
  97. backend: "golangci-lint run"
  98. ```
  99. ---
  100. ## Install
  101. Three ways. Pick one.
  102. ### Option 1: npx (recommended)
  103. ```bash
  104. npx @c0x12c/ai-toolkit@latest --local
  105. ```
  106. Interactive menu. Pick your AI tool and packs. Done in 30 seconds.
  107. ```bash
  108. # Pick specific packs
  109. npx @c0x12c/ai-toolkit@latest --local --packs=backend-micronaut,frontend-react
  110. # Install everything
  111. npx @c0x12c/ai-toolkit@latest --local --all
  112. ```
  113. ### Option 2: Setup script
  114. ```bash
  115. git clone https://github.com/c0x12c/ai-toolkit.git
  116. cd ai-toolkit/toolkit
  117. chmod +x scripts/setup.sh && ./scripts/setup.sh --local
  118. ```
  119. ### Option 3: Claude Code plugin
  120. Search for **"Spartan AI Toolkit"** in the Claude Code plugin marketplace.
  121. ### Local vs Global
  122. - **`--local`** (recommended) &mdash; installs to `./.claude/` in your project. Your team can see, review, and version-control the setup.
  123. - **`--global`** &mdash; installs to `~/.claude/`, works across all your projects.
  124. ### Not using Claude Code?
  125. ```bash
  126. npx @c0x12c/ai-toolkit@latest --local --agent=claude-code # default
  127. npx @c0x12c/ai-toolkit@latest --local --agent=codex # full install
  128. npx @c0x12c/ai-toolkit@latest --local --agent=cursor # rules only
  129. npx @c0x12c/ai-toolkit@latest --local --agent=windsurf # rules only
  130. npx @c0x12c/ai-toolkit@latest --local --agent=copilot # rules only
  131. ```
  132. | Tool | What gets installed | Where |
  133. |------|-------------------|-------|
  134. | **Claude Code** | Commands + rules + skills + agents + CLAUDE.md | `.claude/` |
  135. | **Codex** | Commands + rules + skills + agents + CLAUDE.md | `.codex/` |
  136. | **Cursor** | Rules + AGENTS.md | `.cursor/rules/` |
  137. | **Windsurf** | Rules + AGENTS.md | `.windsurf/rules/` |
  138. | **Copilot** | Rules + AGENTS.md | `.github/instructions/` |
  139. ### Uninstall
  140. ```bash
  141. # Remove from current project
  142. npx @c0x12c/ai-toolkit@latest --uninstall --local
  143. # Remove global install
  144. npx @c0x12c/ai-toolkit@latest --uninstall --global
  145. # Remove for other agents
  146. npx @c0x12c/ai-toolkit@latest --uninstall --local --agent=cursor
  147. ```
  148. ---
  149. ## How It Works
  150. ### Review uses your rules
  151. When `/spartan:build` reaches the review step:
  152. 1. Reads `.spartan/config.yaml` to find your rules
  153. 2. Spawns a separate review agent (fresh eyes, not the same AI that wrote the code)
  154. 3. The reviewer reads all your rule files, then checks the code against them
  155. 4. Issues found &rarr; fix &rarr; re-review &rarr; repeat until clean
  156. No config? The reviewer still runs &mdash; it just uses a generic checklist.
  157. ### Skills: domain knowledge at each step
  158. Leaders call the right skill at the right time based on your stack:
  159. | Skill | When the leader calls it |
  160. |-------|------------------------|
  161. | `kotlin-best-practices` | During build (Kotlin files) |
  162. | `database-patterns` | During plan + build (migration tasks) |
  163. | `ui-ux-pro-max` | During design + build (React components) |
  164. | `testing-strategies` | During build (test tasks) |
  165. | `security-checklist` | During review (security scan) |
  166. ### Agent memory: context across sessions
  167. AI forgets everything when you close the terminal. Agent memory fixes that with 3 layers:
  168. ```
  169. .memory/
  170. index.md — Layer 1: always loaded, pointers only (~150 chars per line)
  171. decisions/ — Layer 2: loaded on demand when relevant
  172. patterns/ — architecture decisions, code patterns
  173. knowledge/ — domain facts, API gotchas
  174. blockers/ — known issues and workarounds
  175. transcripts/ — Layer 3: never loaded, grep-only archive
  176. ```
  177. | Layer | Loaded | Purpose |
  178. |-------|--------|---------|
  179. | Index | Every turn | Quick lookup &mdash; what do we know? |
  180. | Topics | On demand | Full knowledge when the task needs it |
  181. | Transcripts | Never (grep only) | "What did we try last week?" without wasting context |
  182. Leaders read and write memory automatically. `/spartan:memory-consolidate` cleans stale entries. `/spartan:magic-doc` keeps docs in sync with code.
  183. ### Configurable rules
  184. Rules load every session. The AI follows them without you asking.
  185. ```bash
  186. /spartan:init-rules go-standard # Pick a profile
  187. /spartan:scan-rules # Or auto-detect from your code
  188. /spartan:lint-rules # Validate your config
  189. ```
  190. ### Parallel builds
  191. Build 2+ features at the same time. Each `/spartan:build` automatically creates a git worktree &mdash; no manual setup:
  192. ```bash
  193. # Terminal 1 # Terminal 2
  194. /spartan:build auth /spartan:build payments
  195. # → .worktrees/auth/ (feature/auth) # → .worktrees/payments/ (feature/payments)
  196. # → PR #1 # → PR #2
  197. ```
  198. Each build creates its own worktree, branch, and PR. No conflicts. Worktrees are cleaned up after PR merge.
  199. ### Project config
  200. Customize any command per project. Two config files in `.spartan/`:
  201. **`.spartan/build.yaml`** &mdash; controls the build workflow:
  202. ```yaml
  203. branch-prefix: "feature" # branch name: [prefix]/[slug]
  204. max-review-rounds: 3 # review-fix cycles before asking user
  205. skip-stages: [] # skip: spec, design, plan, ship (never review)
  206. prompts: # inject custom instructions per stage
  207. spec: |
  208. Always include performance requirements.
  209. review: |
  210. Check all API responses include request_id.
  211. ship: |
  212. PR title: [PROJ-123] Short description.
  213. ```
  214. **`.spartan/commands.yaml`** &mdash; inject prompts into any command:
  215. ```yaml
  216. prompts:
  217. review: "Flag any function longer than 50 lines."
  218. pr-ready: "Always add Reviewers: @backend-team."
  219. daily: "Include blockers section."
  220. debug: "Always check CloudWatch logs first."
  221. ```
  222. Templates in `toolkit/templates/`. The AI reads your config every session &mdash; no manual reminders needed.
  223. ---
  224. ## Pick Your Packs
  225. Packs group commands, rules, skills, and agents by use case. **Core is always installed.** You pick the rest.
  226. ### Common setups
  227. | Situation | Command |
  228. |-----------|---------|
  229. | Kotlin + Micronaut backend | `--packs=backend-micronaut` |
  230. | React + Next.js frontend | `--packs=frontend-react` |
  231. | Full-stack (Kotlin + Next.js) | `--packs=backend-micronaut,frontend-react` |
  232. | Exploring startup ideas | `--packs=research` |
  233. | Everything | `--all` |
  234. ### All packs
  235. | Pack | Category | Auto-pulls | What's inside |
  236. |------|----------|------------|---------------|
  237. | **core** | Core | &mdash; | Always installed. Workflows + safety + configurable rules |
  238. | **backend-micronaut** | Backend | database, shared-backend | Kotlin + Micronaut: commands, rules, skills, agents |
  239. | **backend-nodejs** | Backend | database, shared-backend | Coming soon |
  240. | **backend-python** | Backend | database, shared-backend | Coming soon |
  241. | **frontend-react** | Frontend | &mdash; | React + Next.js: commands, rules, skills |
  242. | **product** | Planning | &mdash; | Product thinking before building |
  243. | **ops** | Ship | &mdash; | Deploy + environment management |
  244. | **research** | Research | product | Full startup pipeline: idea to investor |
  245. ---
  246. ## All Commands
  247. Type `/spartan` for the smart router. Or go direct:
  248. ### Workflow Leaders
  249. | Leader | Command | Pipeline |
  250. |--------|---------|----------|
  251. | **Build** | `build [mode] [feature]` | context &rarr; spec &rarr; design? &rarr; plan &rarr; TDD &rarr; review &rarr; PR |
  252. | **Debug** | `debug [symptom]` | known issues &rarr; reproduce &rarr; investigate &rarr; test-first fix &rarr; PR |
  253. | **Startup** | `startup [idea]` | resume check &rarr; brainstorm &rarr; validate &rarr; research &rarr; pitch |
  254. | **Onboard** | `onboard` | memory check &rarr; scan &rarr; map &rarr; setup &rarr; save to memory |
  255. | **Research** | `research [topic]` | frame &rarr; gather &rarr; analyze &rarr; report |
  256. ### Core (always installed)
  257. | Command | What it does |
  258. |---------|-------------|
  259. | `spec "feature"` | Write a feature spec &mdash; saves to `.planning/specs/` |
  260. | `plan "feature"` | Implementation plan from spec &mdash; saves to `.planning/plans/` |
  261. | `gate-review` | Dual-agent review (builder + reviewer both accept) |
  262. | `daily` | Standup summary from git history |
  263. | `pr-ready` | Full checklist before creating any PR |
  264. | `codex` | Run Codex as a second-opinion reviewer |
  265. | `commit-message-with-codex` | Commit, open PR, then chain into Codex PR review |
  266. | `ship-pr-codex` | Run Codex PR review rounds and apply clear fixes |
  267. | `init-project` | Auto-generate CLAUDE.md from codebase scan |
  268. | `init-rules` | Set up configurable rules for your stack |
  269. | `scan-rules` | Auto-generate rules from code patterns |
  270. | `lint-rules` | Validate your config and rule files |
  271. | `context-save` | Save session state to resume later |
  272. | `magic-doc [file]` | Auto-update a doc file to match current codebase |
  273. | `memory-consolidate` | Clean up agent memory &mdash; deduplicate, remove stale entries |
  274. | `update` | Check for toolkit updates |
  275. | `careful` | Warn before destructive ops |
  276. | `freeze <dir>` | Lock edits to one directory |
  277. | `guard <dir>` | careful + freeze combined |
  278. | `epic "name"` | Break big work into ordered features |
  279. | `brownfield [svc]` | Map existing codebase before touching legacy code |
  280. ### Backend (backend-micronaut pack)
  281. | Command | What it does |
  282. |---------|-------------|
  283. | `kotlin-service "name"` | Scaffold new Micronaut microservice |
  284. | `review` | PR review with your configured rules |
  285. | `testcontainer "type"` | Setup Testcontainers |
  286. | `migration "desc"` | Create database migration |
  287. ### Frontend (frontend-react pack)
  288. | Command | What it does |
  289. |---------|-------------|
  290. | `design "feature"` | Design workflow with dual-agent review |
  291. | `next-app "name"` | Scaffold new Next.js app |
  292. | `next-feature "name"` | Add feature to existing Next.js app |
  293. | `fe-review` | PR review for frontend code |
  294. | `figma-to-code "url"` | Figma design to production React |
  295. | `e2e "feature"` | Setup Playwright E2E testing |
  296. | `js-security` | NPM security audit — setup, deps, CI, Dependabot, incident response |
  297. ### Product (product pack)
  298. | Command | What it does |
  299. |---------|-------------|
  300. | `validate` | Score an idea &mdash; GO / TEST MORE / KILL |
  301. | `teardown` | Deep competitor analysis |
  302. | `interview` | Mom Test interview questions |
  303. | `lean-canvas` | 9-block Lean Canvas |
  304. | `brainstorm` | Generate and rank ideas |
  305. ### Ship (ops pack)
  306. | Command | What it does |
  307. |---------|-------------|
  308. | `deploy "svc" "target"` | Deploy + verify |
  309. | `env-setup "svc"` | Audit env vars across environments |
  310. ### Research (research pack)
  311. | Command | What it does |
  312. |---------|-------------|
  313. | `startup [idea]` | Full pipeline: brainstorm to investor outreach |
  314. | `kickoff [theme]` | Start new idea &mdash; brainstorm + validate |
  315. | `deep-dive [project]` | Market research + competitor teardowns |
  316. | `fundraise [project]` | Pitch materials + investor outreach |
  317. | `pitch [type]` | Investor-facing materials |
  318. | `outreach [investor]` | Draft investor emails |
  319. | `content [source]` | Turn ideas into platform-native content |
  320. | `write [topic]` | Write blog posts and articles |
  321. ---
  322. ## AI-Powered Design (Optional)
  323. The design workflow (`/spartan:ux`) can generate real images for prototypes using Google Gemini.
  324. ### Setup
  325. 1. Get a [Gemini API key](https://aistudio.google.com/apikey)
  326. 2. Create `.spartan/ai.env` in your project root:
  327. ```bash
  328. echo "GEMINI_API_KEY=your-key-here" > .spartan/ai.env
  329. ```
  330. 3. Install Python dependencies:
  331. ```bash
  332. pip install google-genai Pillow
  333. ```
  334. 4. Use it:
  335. ```bash
  336. /spartan:ux prototype # generates images for your design
  337. ```
  338. > **Note:** The installer adds `.spartan/ai.env` to `.gitignore` automatically. If you set this up manually, make sure `.spartan/ai.env` is in your `.gitignore` &mdash; never commit API keys.
  339. ---
  340. ## Telegram Bridge
  341. Control your AI coding sessions from your phone.
  342. ```
  343. Phone (Telegram) <-> Bridge (Node.js) <-> Claude Agent SDK <-> Claude API
  344. ```
  345. See [`bridges/`](bridges/) for setup.
  346. ---
  347. ## Star History
  348. <a href="https://www.star-history.com/?repos=c0x12c%2Fai-toolkit&type=date&legend=top-left">
  349. <picture>
  350. <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=c0x12c/ai-toolkit&type=date&theme=dark&legend=top-left" />
  351. <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=c0x12c/ai-toolkit&type=date&legend=top-left" />
  352. <img alt="Star History Chart" src="https://api.star-history.com/image?repos=c0x12c/ai-toolkit&type=date&legend=top-left" />
  353. </picture>
  354. </a>
  355. ---
  356. ## Contributing
  357. See [CONTRIBUTING.md](CONTRIBUTING.md) for how to add commands, skills, rules, and agents.
  358. ---
  359. ## License
  360. MIT
toolkit/codex/spartan.zsh · Bundled script · 178 lines · 2 findings marked
  1. # Codex helpers — Spartan-style review commands
  2. # Source from ~/.zshrc: [[ -f ~/.codex/spartan.zsh ]] && source ~/.codex/spartan.zsh
  3. #
  4. # Install (project-local copy lives at toolkit/codex/spartan.zsh):
  5. # cp toolkit/codex/spartan.zsh ~/.codex/spartan.zsh
  6. # echo '[[ -f ~/.codex/spartan.zsh ]] && source ~/.codex/spartan.zsh' >> ~/.zshrc
  7. # source ~/.zshrc
  8. # Or run `/spartan:codex setup` from inside Claude Code.
  9. # --- Defaults --------------------------------------------------------------
  10. : "${CDX_BASE:=master}" # default base branch for diffs
  11. : "${CDX_MODEL:=}" # optional: pin a model, e.g. CDX_MODEL=gpt-5.1
  12. : "${CDX_YOLO:=0}" # set to 1 to bypass approvals/sandbox for review helpers
  13. _cdx_model_args() {
  14. [[ -n "$CDX_MODEL" ]] && echo "-m $CDX_MODEL"
  15. }
  16. _cdx_review_args() {
  17. if [[ "$CDX_YOLO" != "0" ]]; then
  18. echo "--dangerously-bypass-approvals-and-sandbox"
  19. else
  20. echo "--ask-for-approval never --sandbox read-only"
  21. fi
  22. }
  23. _cdx_codex() {
  24. codex $(_cdx_review_args) $(_cdx_model_args) "$@"
  25. }
  26. _cdx_exec_review_diff() {
  27. local base="$1"; shift
  28. local instructions="$*"
  29. _cdx_codex review --base "$base" \
  30. "Review every change in the current branch against base '$base', like a full PR review. Start by inspecting 'git diff $base...HEAD --stat' and then the full diff with file context. Do not review unrelated working-tree noise. ${instructions:-Report only actionable findings with severity and file:line.}"
  31. }
  32. _cdx_resolve_base() {
  33. # Prefer the user-provided base; otherwise pick the first branch that exists.
  34. local b="$1"
  35. if [[ -n "$b" ]]; then echo "$b"; return; fi
  36. local origin_head
  37. origin_head=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
  38. if [[ -n "$origin_head" ]] && git rev-parse --verify "origin/$origin_head" >/dev/null 2>&1; then
  39. echo "origin/$origin_head"; return
  40. fi
  41. for cand in master main dev develop; do
  42. if git rev-parse --verify "$cand" >/dev/null 2>&1; then echo "$cand"; return; fi
  43. if git rev-parse --verify "origin/$cand" >/dev/null 2>&1; then echo "origin/$cand"; return; fi
  44. done
  45. echo "$CDX_BASE"
  46. }
  47. # --- cdx-review : one-pass review of the current branch -------------------
  48. # Usage: cdx-review [base-branch] [extra prompt...]
  49. cdx-review() {
  50. local base; base=$(_cdx_resolve_base "$1"); shift 2>/dev/null
  51. local extra="$*"
  52. echo "==> Reviewing vs $base"
  53. if [[ -n "$extra" ]]; then
  54. _cdx_exec_review_diff "$base" "$extra Each finding must be actionable with file:line and the specific fix."
  55. else
  56. _cdx_codex review --base "$base"
  57. fi
  58. }
  59. # --- cdx-pr : review a GitHub PR without touching the current checkout -----
  60. # Usage: cdx-pr <pr-number-or-url> [rounds=2]
  61. cdx-pr() {
  62. local pr="$1"
  63. local rounds="${2:-2}"
  64. if [[ -z "$pr" ]]; then
  65. echo "Usage: cdx-pr <pr-number-or-url> [rounds=2]" >&2
  66. return 1
  67. fi
  68. if ! command -v gh >/dev/null; then
  69. echo "gh CLI not found. Install gh or check out the PR branch manually." >&2
  70. return 1
  71. fi
  72. if ! [[ "$rounds" =~ ^[0-9]+$ ]] || (( rounds < 1 )); then
  73. echo "Usage: cdx-pr <pr-number-or-url> [rounds>=1]" >&2
  74. return 1
  75. fi
  76. local meta number base ref tmp exit_code
  77. meta=$(gh pr view "$pr" --json number,baseRefName --template '{{.number}} {{.baseRefName}}') || return
  78. number="${meta%% *}"
  79. base="${meta#* }"
  80. ref="refs/remotes/origin/pr-$number"
  81. echo "==> Fetching PR #$number vs $base"
  82. git fetch origin "refs/heads/${base}:refs/remotes/origin/${base}" "pull/${number}/head:${ref}" --quiet || return
  83. tmp=$(mktemp -d "${TMPDIR:-/tmp}/cdx-pr-${number}.XXXXXX") || return
  84. if ! git worktree add --detach "$tmp" "$ref" >/dev/null; then
  85. rmdir "$tmp" 2>/dev/null || true
  86. return 1
  87. fi
  88. (
  89. cd "$tmp" || exit 1
  90. cdx-ship "$rounds" "origin/$base"
  91. )
  92. exit_code=$?
  93. git worktree remove "$tmp" --force >/dev/null 2>&1 || true
  94. return "$exit_code"
  95. }
  96. # --- cdx-ship : multi-round escalating review (mirrors /spartan:ship-pr-codex) ----
  97. # Usage: cdx-ship [rounds=2] [base-branch]
  98. cdx-ship() {
  99. local rounds=${1:-2}
  100. local base; base=$(_cdx_resolve_base "$2")
  101. if ! [[ "$rounds" =~ ^[0-9]+$ ]] || (( rounds < 1 )); then
  102. echo "Usage: cdx-ship [rounds>=1] [base-branch]" >&2; return 1
  103. fi
  104. echo "==> ship-pr-codex: $rounds round(s) vs $base"
  105. for i in $(seq 1 "$rounds"); do
  106. echo
  107. echo "================ Round $i / $rounds ================"
  108. local stance
  109. case "$i" in
  110. 1) stance="Pass 1: surface review. Catch obvious bugs, missing tests, broken contracts." ;;
  111. 2) stance="Pass 2: harder. Question every assumption pass 1 made. Find what was waved through. Look for race conditions, N+1, error swallowing, missing edge cases." ;;
  112. *) stance="Pass $i: brutal. Assume every previous pass missed real issues. Find them. Reject anything that smells like AI-generic code, premature abstraction, or untested branches." ;;
  113. esac
  114. echo "==> $stance"
  115. _cdx_exec_review_diff "$base" "$stance Each finding must be actionable with file:line and the specific fix."
  116. done
  117. }
  118. # --- cdx-security : security-focused review --------------------------------
  119. # Usage: cdx-security [base-branch]
  120. cdx-security() {
  121. local base; base=$(_cdx_resolve_base "$1")
  122. echo "==> Security review vs $base"
  123. _cdx_exec_review_diff "$base" \
  124. "Security audit only. Check: input validation, authn/authz, SQL/command injection, SSRF, secrets in code, unsafe deserialization, missing rate limits, IDOR, weak crypto, log injection, OWASP top 10. Ignore style and non-security bugs. Rate severity critical/high/medium and give the exact fix."
  125. }
  126. # --- cdx-uncommitted : review what's in the worktree, not yet committed ----
  127. cdx-uncommitted() {
  128. local extra="$*"
  129. echo "==> Reviewing uncommitted changes"
  130. _cdx_codex review --uncommitted \
  131. "${extra:-Review staged, unstaged, and untracked changes. Catch issues before commit.}"
  132. }
  133. # --- cdx-commit : review a single commit -----------------------------------
  134. # Usage: cdx-commit <sha>
  135. cdx-commit() {
  136. local sha="$1"
  137. if [[ -z "$sha" ]]; then echo "Usage: cdx-commit <sha>" >&2; return 1; fi
  138. shift
  139. _cdx_codex review --commit "$sha" "$@"
  140. }
  141. # --- cdx-yolo : Codex with no approvals & no sandbox -----------------------
  142. # Equivalent of Claude's --dangerously-skip-permissions. Use with care.
  143. cdx-yolo() {
  144. codex --dangerously-bypass-approvals-and-sandbox $(_cdx_model_args) "$@"
  145. }
  146. # --- cdx-help : list these helpers -----------------------------------------
  147. cdx-help() {
  148. cat <<'EOF'
  149. Codex helpers (override defaults: CDX_BASE=master CDX_MODEL=gpt-5.1 CDX_YOLO=1)
  150. cdx-review [base] [prompt...] One-pass review of current branch vs base
  151. cdx-pr <pr-number-or-url> [rounds] Review a PR in a temporary worktree
  152. cdx-ship [rounds] [base] Multi-round escalating review (default 2)
  153. cdx-security [base] Security-only audit
  154. cdx-uncommitted [prompt...] Review staged + unstaged + untracked
  155. cdx-commit <sha> [prompt...] Review a single commit
  156. cdx-yolo [prompt...] Codex with no approvals & no sandbox
  157. cdx-help This message
  158. EOF
  159. }

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.