altk-evolve icon indicating copy to clipboard operation
altk-evolve copied to clipboard

feat(claude-plugin): add synthesize-skill skill + experiment runner

Open vinodmut opened this issue 6 months ago • 2 comments

Summary

Adds a new evolve-lite skill that converts a saved trajectory into a reusable Claude Code skill (SKILL.md + supporting scripts), plus a standalone experiment driver that compares this procedural memory path against the existing declarative recall (guidelines) path and a no-memory baseline.

This is the runner + skill only. Result artifacts from my own runs against the EXIF demo are kept on procedural; headline numbers and the writeup are on issue #260.

What's in here

platform-integrations/claude/plugins/evolve-lite/skills/evolve-lite/synthesize-skill/

A new skill that mirrors the shape of learn:

  • SKILL.md — instructions the forked subagent follows: read the trajectory, identify the successful workflow, draft a SKILL.md and any scripts.
  • scripts/synthesize.py finalize — file-system plumbing: validates frontmatter, dual-writes to both .evolve/skills/<name>/ and .claude/skills/<name>/, appends a synthesize_skill event to .evolve/audit.log.

The split mirrors learn's pattern: judgment in the subagent, plumbing in a Python script. The skill is invoked manually for now — not wired into a Stop hook.

experiments/skill_from_trajectory.py

Three-way comparison driver (no_recall / guidelines / skill). Per trial:

  1. Seed the workspace by running one or more utterances (default: gps). Each fires the existing learn Stop hook.
  2. Invoke /evolve-lite:synthesize-skill on the seed trajectory.
  3. Branch into three condition workspaces and run measure utterance(s) in each.
  4. Capture token usage, per-turn breakdown, and tool-call summaries.

Supports --seed-utterances for multi-utterance seeding to test skill generalization (e.g. --seed-utterances gps focal_length then measure on lens). Reuses helpers from experiments/token_savings.py.

Also includes a small fix for macOS Docker bind-mount behavior: resolves /tmp → /private/tmp so subdirectories of /tmp are visible inside the sandbox container (the prior token-savings experiment got away with this because pytest's tmp_path is under /private/var/...).

Test plan

  • [ ] python3 experiments/skill_from_trajectory.py --help lists --trials, --seed-utterances, --utterances, --keep-workspaces.
  • [ ] python3 platform-integrations/claude/plugins/evolve-lite/skills/evolve-lite/synthesize-skill/scripts/synthesize.py finalize --help works.
  • [ ] Smoke run: python3 experiments/skill_from_trajectory.py --trials 1 --utterances focal_length end-to-end (requires Docker, the claude-sandbox image, and Anthropic API credentials). Should produce experiments/results/skill_from_trajectory_<ts>/{report.md, raw.json, synthesized_skills/}.

Related

  • #260 — the issue this work informs (procedural memory results posted as a comment).
  • #261 — earlier PR that added the declarative-recall (guidelines) experiment driver. Pattern reused here.

Summary by CodeRabbit

  • New Features

    • Convert saved trajectories into reusable, validated agent skills via a finalize/install CLI (with overwrite option) and mirror installs for runtime platforms.
    • New benchmark experiment that runs seeded trials across three recall conditions, records per-run token/cost/duration/turn metrics, and collects synthesized-skill artifacts.
  • Documentation

    • Added user-facing guides, templates, and best-practice rules for the synthesize workflow and validation.

vinodmut avatar Jun 01 '26 15:06 vinodmut

Review Change Stack

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds synthesize-skill templates and platform finalize CLIs plus SKILL.md docs, and introduces experiments/skill_from_trajectory.py which seeds trajectories, invokes synthesize-skill, and benchmarks three recall conditions with progressive raw results and a generated report.md.

Changes

Skill Synthesis Workflow and Implementation

Layer / File(s) Summary
Plugin templates
plugin-source/skills/evolve-lite/synthesize-skill/SKILL.md.j2, plugin-source/skills/evolve-lite/synthesize-skill/scripts/synthesize.py.j2
Jinja2 templates that produce platform-specific SKILL.md and synthesize.py finalize helper including conditional runtime mirroring and optional Claude fork context.
Platform SKILL.md documentation & command guidance
platform-integrations/*/skills/evolve-lite/synthesize-skill/SKILL.md, platform-integrations/bob/evolve-lite/commands/evolve-lite-synthesize-skill.md
Deployed SKILL.md and command guidance describing trajectory sourcing, extracting the final successful tool sequence, drafting required SKILL.md frontmatter, optional scripts, finalize invocation, collision handling, and best-practice rules.
Platform synthesize.py implementations
platform-integrations/*/skills/evolve-lite/synthesize-skill/scripts/synthesize.py
Finalize CLI that locates plugin audit helper, parses minimal frontmatter, validates kebab-case --name and required keys, copies draft into .evolve/skills/<name> (and optional runtime mirror), appends an audit-log entry, prints installed paths, and supports --force.

Skill Synthesis Benchmarking Experiment

Layer / File(s) Summary
Experiment framework
experiments/skill_from_trajectory.py (imports, runner, utilities)
Adds CLI and constants, Docker/macOS-backed sandbox runner executing claude with JSON fallback parsing, workspace creation/copy helpers, transcript parsing for tool-call summaries, and usage extraction including total_cost_usd.
Experiment benchmarking and reporting
experiments/skill_from_trajectory.py (trial loop, branching, measures, reporting)
Implements seed→synthesize step, branches per-condition workspaces (no_recall, guidelines, skill), runs measures capturing headline usage, per-turn metrics and tool-call summaries, persists progressive raw.json, copies synthesized skills into results, writes report.md with synthesis-cost and cross-condition comparison, and provides CLI orchestration (exit code 1 if any run errors).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • #219 — The changes implement synthesize-skill templates, per-platform finalize scripts, and experiment benchmarking described by this issue.

Suggested reviewers

  • visahak
  • illeatmyhat

Poem

🐰 From saved steps I stitched a clever art,

I found the end and gave it a start.
Three workspaces ran, the reports took flight,
Templates and skills tucked in just right.
Hooray — a rabbit hop for code tonight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main additions: a new synthesize-skill feature for the Claude plugin and an experiment runner script comparing skill-based vs. guideline-based vs. baseline recall.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jun 01 '26 15:06 coderabbitai[bot]

No vulnerabilities found.

agent-toolkit-owl avatar Jun 05 '26 01:06 agent-toolkit-owl