Optimize by AI Agents
Run an end-to-end optimization session driven by an AI agent: install the
Claude Code slash commands into your project,
scope a measurable target with /codespine-interview,
and apply a verified-safe edit with /codespine-optimize.
The agent runtime is Claude Code itself, so there is no API key or LLM provider to
configure.
Setup
-
Open the project you want to optimize. It must be a TypeScript project with a
tsconfig.json— see the prerequisites. -
Install the codespine assets into the project’s
.claude/directory. Run this from the root of the repository; it creates.claude/for you (seeinstallfor options):npx codespine install -
Start Claude Code from the root of the repository:
claude -
Scope a target. Launch the interview — it is read-only and asks you questions to pin down a measurable optimization target, grounding each candidate in the graph:
/codespine-interview -
Apply an optimization. The interview often proposes this command for you, but you can also run it on its own with an explicit target:
/codespine-optimize /codespine-optimize the database FooBar needs an index
See Agent slash commands for what each command does.
Keep a record of the session
A session leaves a git diff behind, but it helps to capture the reasoning too:
-
Open a GitHub issue about the session. Ask Claude directly — for example, “create a GitHub issue about this optimization session” — so the what and why are tracked alongside the diff.
-
Export the transcript to markdown with Claude Code’s
/exportcommand:/export /path/to/session.md
See also
- Agent slash commands — what each
/codespine-*command does. - The pipeline — extract → load → query → run the agent on its first verified edit.
install— the command that drops the slash commands into.claude/.