This project provides an Agent Optsmith workflow for measurable AI coding optimization. This README is the main entry point for installation and daily operation.
Companion docs:
After setup, you get a repeatable optimization workflow with concrete outputs:
- Automatic run logging + metrics + weekly review with one command.
- Skill impact reports (
token_reduction_pct,duration_reduction_pct, etc.). - Filterable local web dashboard (date, skill, cutover, metric key filter).
- Skill optimization discovery with immediate optimize/create actions from dashboard.
- Clear pre/post comparison around a chosen cutover date.
In your project, data is stored under .agents/optsmith-data/:
metrics/task-runs.csvknowledge-base/errors/reports/templates/error-entry.md
Use either Homebrew or pipx:
brew tap korilin/optsmith https://github.com/korilin/agent-optsmith
brew install optsmithpipx install "git+https://github.com/korilin/agent-optsmith.git"Then verify the CLI entrypoint:
optsmith version
optsmith helpRun this in the target project root:
optsmith install --workspace "$(pwd)"Install parameters:
--workspace <path>: target project directory (default: current directory).--data-dir <path>: data root used for metrics/KB/reports (default:.agents/optsmith-data).--skill-path <path>: project skill root whereagent-optsmithis installed (default:.agents/skills).--skip-agents: skip writing/updating the managedOPTSMITH-SKILLblock inAGENTS.md.
Path behavior:
- Relative paths are resolved relative to
--workspace. - For safety,
data-dirandskill-pathmust stay inside the workspace.
Custom path example:
optsmith install \
--workspace "$(pwd)" \
--data-dir ".agents/custom-optsmith-data" \
--skill-path ".agents/custom-skills"Expected result:
.agents/optsmith-data/metrics/task-runs.csvcreated (with header)..agents/optsmith-data/knowledge-base/errors/created..agents/optsmith-data/reports/created..agents/optsmith-data/templates/error-entry.mdcreated.<workspace>/.agents/skills/agent-optsmithinstalled from current CLI version.AGENTS.mdgets/refreshes a managedOPTSMITH-SKILLblock withskill_diranddata_dir.
- In agent workflow, this command should be auto-executed at task completion (collect + analyze + review):
optsmith run --workspace "$(pwd)" \
--task-id TASK-1001 \
--task-type debug \
--model gpt-5 \
--used-skill true \
--skill-name log-analysis-helper \
--total-tokens 1820 \
--duration-sec 420 \
--success true \
--rework-count 0If telemetry is not passed explicitly, optsmith run will try to resolve real values from
local Codex session logs ($CODEX_HOME/sessions and $CODEX_HOME/archived_sessions, using
CODEX_THREAD_ID when available). For non-Codex runners, keep passing total_tokens /
duration_sec (or set env vars such as CODEX_TOTAL_TOKENS and CODEX_TASK_DURATION_SEC).
- Open dashboard for filtering, optimization discovery, and direct optimization:
optsmith dashboard --workspace "$(pwd)" --host 127.0.0.1 --port 8765Then open http://127.0.0.1:8765.
Use the Skill Optimization Discovery section to optimize one skill immediately.
Use New Skill Recommendations to create-and-optimize a new skill immediately.
New or optimized skill files are written under project .agents/skills/ by default
(Codex auto-readable project skill directory).
Legacy fallback scan for project skills/ is disabled. If you need a custom path,
set OPTSMITH_LOCAL_SKILLS_DIR.
- Optional direct report commands (if you need raw CLI output):
optsmith metrics --workspace "$(pwd)" --all
optsmith metrics --workspace "$(pwd)" --skill log-analysis-helper
optsmith metrics --workspace "$(pwd)" --all --cutover YYYY-MM-DD
optsmith optimize --workspace "$(pwd)" --skill log-analysis-helper- Update project-installed skill to current CLI version:
optsmith update --workspace "$(pwd)"- Uninstall project integration when needed:
optsmith uninstall --workspace "$(pwd)"- Task completion and context confirmation:
- ensure stable
task_idfor reopened work - confirm
task_type,skill_name,success, andrework_count
- Run automation entry:
- execute
optsmith runwith available telemetry and metadata - normalize one task record format
- Persist task sample:
- append one row to
.agents/optsmith-data/metrics/task-runs.csv - keep token/duration/success/rework fields complete
- Compute metrics:
- generate overall, per-skill, and cutover sections
- produce dashboard/weekly-review inputs
- Discover opportunities:
- evaluate optimization opportunities for existing skills
- generate recommendations for potential new skills
- Apply optimization:
- trigger optimization action and update skill content
- write optimization report and snapshot
- Verify and govern:
- compare before/after windows by cutover
- promote only verified improvements
- continue the same loop on next tasks
- Skill-level effect:
- Each skill is compared only with no-skill baseline rows from the same
task_type. token_reduction_pct = (baseline_avg_tokens - skill_avg_tokens) / baseline_avg_tokensduration_reduction_pct = (baseline_avg_duration - skill_avg_duration) / baseline_avg_durationsuccess_rate_delta_pp = skill_success_rate - baseline_success_raterework_rate_delta = skill_rework_rate - baseline_rework_rate
- Process-level pre/post effect (cutover):
prewindow:date < cutoverpostwindow:date >= cutoverdelta_avg_tokens_pct = (post_avg_tokens - pre_avg_tokens) / pre_avg_tokensdelta_avg_duration_pct = (post_avg_duration - pre_avg_duration) / pre_avg_durationdelta_success_rate_pp = post_success_rate - pre_success_ratedelta_tasks_per_day_pct = (post_tasks_per_day - pre_tasks_per_day) / pre_tasks_per_day
- Suggested validation sequence:
- Run
optsmith metrics --workspace "$(pwd)" --skill <skill-name>for skill-vs-baseline effect. - Run
optsmith metrics --workspace "$(pwd)" --all --cutover YYYY-MM-DDfor pre/post process effect. - In dashboard, apply date + skill filter to inspect trend consistency before concluding.
- Optimization events are persisted in project files:
.agents/optsmith-data/reports/dashboard-optimization-state.json(updated_at, action, score, status)..agents/optsmith-data/reports/optimization-history/<skill>.md(timestamped optimization log).- The optimized skill
SKILL.mdauto snapshot block (updated_at, status, source report).
-
The recommended cutover is the optimization event date (
updated_at->YYYY-MM-DD). -
This is the standard comparison rule:
before: task rows withdate < cutover.after: task rows withdate >= cutover.- Keep the same
task_typebaseline requirement when interpreting skill deltas.
- Current data granularity is day-level (
date), not timestamp-level:
- If multiple optimizations happen on the same day, they share one cutover day window.
- For strict separation, avoid multiple optimizations per day for the same skill, or temporarily version skill names during evaluation.
- Task identity contract:
task_idmust remain stable when the same business task is reopened.
- Rework identification contract:
- If a delivered task is reopened (QA fail, requirement miss, rollback fix), log the next completion with the same
task_idand incrementedrework_count. rework_count=0means first-pass completion.rework_count=1/2/...means reopen rounds occurred before this completion.
- Current rework metric formula in the toolkit:
rework_rate = SUM(rework_count) / COUNT(task_rows)
- Important operational note:
- The system does not infer rework across different
task_idvalues. - If your team changes
task_idon reopen, rework will be undercounted.
- Existing skill opportunity score increases when signals appear:
- insufficient baseline on matching task types
- token or duration regression vs baseline
- success rate drop
- rework rate increase
- New skill recommendation score increases when signals appear:
- no-skill repeats for a task type (
>=3samples) - no-skill token/duration cost is high vs overall
- failure/rework is high
- recurring root cause appears in error KB
- Trigger timing:
- on every
optsmith run - on every dashboard
/api/reportrefresh
- Do not claim skill gains when output says
insufficient baseline. - Read token, success, and rework metrics together.
- Only compare same
task_typefor skill effect. - Ensure both pre and post windows have enough samples before using cutover deltas.
- Treat optimization as verified only after post-window metrics stay improved, not after one short burst.
- Initialize in current project:
optsmith install --workspace "$(pwd)"
- Record and analyze one completed task:
optsmith run --workspace "$(pwd)" ...
- Open local dashboard:
optsmith dashboard --workspace "$(pwd)" --host 127.0.0.1 --port 8765
- Inspect metrics directly:
optsmith metrics --workspace "$(pwd)" --alloptsmith metrics --workspace "$(pwd)" --skill <skill-name>
- Upgrade or remove project integration:
optsmith update --workspace "$(pwd)"optsmith uninstall --workspace "$(pwd)"