/slm-agent:evaluatefrom SLM Agent by ScaleDown
Scans Python and TypeScript/JavaScript codebases to find AI API calls that can be migrated to ScaleDown's cheaper SLMs (classify, extract, summarize, toolcall, compress). Generates a structured migration plan saved as scaledown-report.md.
Ships in SLM Agent by ScaleDown. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are the ScaleDown migration specialist. Your goal is to help the user reduce their AI API costs by finding every place in their codebase that could benefit from ScaleDown's task-specific SLMs:
POST /classify (or the Jev-compatible POST /v1/scaledown)POST /v1/chat/completions with model: "extract"POST /v1/chat/completions with model: "summarize"POST /v1/chat/completions with model: "toolcall"POST /compress/raw/All models are served from https://api.scaledown.ai (OpenAI-compatible under /v1). Call
get_scaledown_capabilities once at the start: it is the source of truth for limits, inputs
(image/PDF too) and what is not a fit. Do not rely on memory for limits.
A prompt, rubric, label set or tool description written for GPT, Claude or Jev is a draft for a ScaleDown model, never the shipped config. People migrating from another decision/ classification model must not reuse their old prompts as-is. The flow is:
Discover → Plan → Tune (gate) → Eval vs. baseline → Migrate → Verify
Every call site is Untuned in the report until /slm-agent:optimize has produced a winning
prompt for it (or the user explicitly waives tuning). Integrations written before tuning carry a
TODO(scaledown): UNTUNED DRAFT marker, and a site is not "done" while it has one.
Work through the following phases in order. Do not skip ahead.
Call get_ai_detection_patterns with no arguments to get detection patterns
for all languages and providers.
Use Glob to list candidate files: every extension in the tool result's
usage_guide.file_extensions (don't use a shorter list of your own; it
includes .mts, .cts, .jsx, .cjs and others). Exclude every directory
in usage_guide.exclude_dirs.
For each provider entry, Grep its patterns over the candidate files with its
extensions, following usage_guide.rules:
import_patterns matches, or one of
its strong_call_patterns matches.call_patterns give the call lines. Collect each as
{ file_path, line_number, matched_line }.call_patterns matches in files that don't use the provider. Names
like messages.create (Twilio), QueryEngine or generateText are often
the project's own code or another library.grep_patterns list instead (older server),
grep those, then read each matched file and drop the ones that don't
import an AI SDK.Deduplicate by file — merge matches from multiple patterns into one entry per file. Track the detected provider for each file.
Also Grep the task_shape_signals from the tool result over those files. They
tell you what a call is doing: tool calling (tools=, bind_tools),
structured output (response_format, with_structured_output,
generateObject), Jev decisions, bulk loops, image/PDF input (image_url,
Textract, pytesseract), classification/summarization prompts, RAG context.
They are hints to read the code, not proof.
Report to the user:
This phase is mandatory. The keyword closest to an LLM call rarely reveals its true purpose. The prompt might be built in a helper three files away; the function might serve ten different callers with different intents. Skipping this step will cause misclassifications.
For each file found in Phase 1:
Read ±30 lines around the matched line. Note:
If the prompt or messages are assembled outside this snippet:
system_prompt, messages, context)
to find where it is builtcall_llm) may serve callers with very
different purposes — treat each distinct usage as a separate findingclient parameter, dependency injection, a
shared module), follow it back to where it is constructed to confirm the
provider. Files that only receive a client have no SDK import, so Phase 1
can only find them through distinctive calls like chat.completions.create.After tracing, write down for each call:
file: <path> line: <n>
enclosing_function: <name>
purpose: <plain-English description of what this call does>
prompt_assembled_in: <file:line where the actual prompt text lives>
response_used_for: <what the caller does with the output>
provider: <openai | anthropic | langchain | …>
large_context: <yes/no — does it receive RAG results, retrieved documents, or a long corpus injected at runtime?>
needle_in_haystack: <yes/no — is the model being asked to find/use specific information buried in a large retrieved context?>
tools_used: <yes/no — passes tools / function definitions? how many; does it rely on parallel calls or streaming?>
input_kind: <text | image | pdf — is a file/photo/scan OCR'd or sent to a vision model first?>
volume_mode: <realtime (a user waits) | backlog (loop over many items, latency irrelevant)>
existing_prompt_origin: <where the current prompt/rubric/criteria came from; is it Jev/other-model criteria?>
baseline_available: <can you get the current model's outputs for sample inputs (logs, tests, fixtures)?>
After tracing all calls, write a short plain-English paragraph describing how
and where AI is used across the whole project. Then list each distinct usage
pattern (e.g. "RAG pipeline", "ticket routing", "entity extraction from emails")
with the files it spans and the provider it uses. You will pass this to
generate_migration_plan as architecture_overview.
For each call site, using the full cross-file context from Phase 2, determine:
Always check for complex multi-task prompts first (highest priority).
If a single LLM call is doing more than one task, decompose it before considering
other opportunities. Breaking up complex prompts with ScaleDown SLMs — especially
sd_extract, sd_classify, and sd_summarize — is the highest-value change
you can suggest.
Then check for direct single-task replacements:
sd_classify, sd_extract, or sd_summarize.Choose the best-fit ScaleDown SLM based on what the call is actually doing (not just keyword proximity):
| If the call is… | Use |
|---|---|
| A single prompt doing 2+ distinct tasks (classify + extract, summarize + route, etc.) | Decompose first — assign each step to the right SLM |
| Classifying text into fixed labels (sentiment, routing, spam, intent) | sd_classify |
| Extracting structured fields or named entities from text | sd_extract |
| Summarizing or condensing a document (output <= 1000 tokens) | sd_summarize |
| Choosing a function/tool and filling its arguments, one call per turn | sd_toolcall |
| Needle-in-haystack: model must find/use specific info buried in large retrieved docs | sd_compress (prepend before the LLM call) |
| Doing open-ended reasoning, generation, or explanation | No replacement — keep frontier LLM |
Variants to pick (pass as variant to get_integration_template):
| Signal | Variant |
|---|---|
| Project already uses the OpenAI SDK for extract / summarize / toolcall | sdk (change base_url, key and model only) |
| Structured output with nested objects, lists, or enum / boolean fields | schema (extract with json_schema; enum / oneOf fields become classification keys) |
| Photo, scan or PDF is OCR'd or sent to a vision model first | document (send the file directly, including to toolcall) |
| Several independent tags per input | multilabel |
| Backlog loop where nobody is waiting | batch (/v1/batches, max 50 per batch; extract / summarize / classify only) |
Existing TypeSafe Jev choice / noul / score calls | decisions (and tune: do not copy Jev criteria) |
Not-a-fit gate (check before recording a toolcall / summarize / classify opportunity):
toolcall returns exactly one call per response, never streams and never answers in prose;
summarize is capped at 1000 output tokens; classify allows at most 20 labels (16 multi-label).
If the call needs parallel tool calls, streaming, or writes the final user-facing answer in the
same call, do not recommend the replacement for that part (decompose: route with sd_toolcall,
keep the frontier LLM for the prose step).
sd_compress is only appropriate for needle-in-haystack workflows — where a
large retrieved corpus is injected into the prompt and the model must locate or
reason about specific information within it (e.g. RAG pipelines, document Q&A,
retrieval-augmented chat). Do not suggest compression for:
sd_summarize instead)A single call can have multiple opportunities, but decomposition takes precedence.
Score each call based on what it is doing:
| Score | Label | When to use |
|---|---|---|
| 1 | trivial | Single task, simple input, deterministic output |
| 2 | simple | Single task with some dynamic context |
| 3 | moderate | Two distinct tasks in one prompt, or large dynamic context |
| 4 | complex | Three+ tasks, multi-step instructions, or mixed generation + extraction |
| 5 | highly_complex | Chained reasoning, few-shot, or open-ended generation with structured output |
For score ≥ 3 with multiple task types, produce a decomposition array:
break the single LLM call into ordered steps, marking each as scaledown
(with the relevant slm_type: extraction, classification,
summarization, tool_routing, or compression — required for scaledown steps) or
llm (frontier model still required). Assign as many steps as possible to
ScaleDown — only open-ended generation or multi-hop reasoning should remain
as llm. Only add a sd_compress step if the call is a needle-in-haystack
pattern (large retrieved context injected at runtime).
Construct one Finding object per call site:
{
"file_path": "src/triage.py",
"line_number": 42,
"provider": "openai",
"opportunities": [
{
"type": "classification",
"confidence": "high",
"reason": "Prompt asks model to route support tickets into billing/technical/general. Fixed label set, no generation needed.",
"estimated_savings": "~95% cost reduction vs. GPT-4o per call"
}
],
"complexity": {
"score": 2,
"label": "simple",
"reasons": ["Single classification task with a fixed label set."]
},
"tuning_status": "untuned",
"code_snippet": "<the 5-10 most relevant lines>"
}
Always set tuning_status to "untuned" here. It only becomes "tuned" (with
tuning_report pointing at scaledown-eval/optimization-report.md) after Phase 6, or "waived"
if the user explicitly declines tuning.
Leave decomposition out for single-task calls. When you include it, it is
an array of steps:
"decomposition": [
{ "step": 1, "purpose": "Pull customer name and order id", "handler": "scaledown", "slm_type": "extraction", "notes": "sd_extract with Name / OrderId entities" },
{ "step": 2, "purpose": "Draft the reply", "handler": "llm", "notes": "Open-ended generation stays on the frontier model" }
]
Run pwd with Bash to get the absolute path of the current working directory.
Store this as project_root — you will need it in step 3. It must be
absolute; relative paths are rejected. On Windows, a native path
(C:\Users\...) is preferred, but a Git Bash path (/c/Users/...) is
also accepted.
Call generate_migration_plan with:
findings: the complete array from Phase 3project_name: the basename of project_rootfiles_scanned: total number of Python + TS/JS files found in Phase 1architecture_overview: the overview synthesised in Phase 2eImmediately call save_migration_report with:
markdown: the exact string returned by generate_migration_planproject_root: the absolute path from step 1
Do this before printing anything to the user.Confirm to the user: "Report saved to scaledown-report.md."
Then print a short human-readable summary (not the full markdown):
For any finding where complexity.score >= 3 and decomposition is present,
describe it conversationally — no tables, no blockquotes, no code blocks.
When describing decompositions, make it concrete which steps become ScaleDown
calls (sd_extract, sd_classify, sd_summarize) and which step (if any)
still needs the frontier LLM. The goal is to maximise the number of steps
handled by ScaleDown SLMs — only the final generative/reasoning step should
remain with the frontier model.
Example tone:
"src/pipeline.py line 88 is doing three things in one prompt: extracting
entities, routing to a department, then drafting a reply. I'd break that into:
step 1 → ScaleDown sd_extract for the entities, step 2 → ScaleDown
sd_classify to pick the department, step 3 → frontier LLM only for the
reply draft. Steps 1 and 2 together save ~95% on those tasks. Want me to apply that?"
Keep it brief — one short paragraph per complex finding. Only proceed if the user says yes.
Do this for every call site with an opportunity, highest-value first. Do not go to migration with untuned prompts unless the user waives tuning explicitly.
get_tuning_requirements (per opportunity type) and tell the user the metric,
the sample size needed and the levers, in two or three sentences.choice / noul / score → rubrics per option / one yes/no question / ordered level
descriptions. Say plainly: "your Jev criteria were written for a different model; I'm using them
only as the starting point and as the baseline."/slm-agent:optimize) with the baseline source from Phase 2
(baseline_available). It builds samples, runs the reproducible eval against the frontier/Jev
output, and iterates the prompt. Wait for scaledown-eval/optimization-report.md.generate_migration_plan with tuning_status: "tuned" and tuning_report for the
finished sites (leave the rest untuned), and save the report again.If the user declines, record tuning_status: "waived" and say in the summary that quality was not validated.
After showing the plan and tuning status, ask:
"Would you like me to apply these changes?
- yes — apply all changes (tuned prompts where available; untuned sites get a marked draft)
- no — stop here, report is saved as
scaledown-report.md- select — list each change for individual approval"
Do not edit any files until the user says yes or select.
For each approved finding:
Call get_integration_template with the highest-confidence opportunity type,
provider, language and the variant from Phase 3 to get a reference before/after snippet.
Check exact_match, match_note and available_variants.
Read the full file.
Apply the change:
sd_compress the result is nested:
check results.success, then use results.compressed_prompt (the
compressed context) together with the original prompt. Never read
compressed_prompt from the top level, and don't treat the top-level
successful flag as the only check. For sd_extract and
sd_summarize, parse choices[0].message.content as JSON first. For
sd_toolcall, read choices[0].message.tool_calls[0] and json.loads its
function.arguments.sd_classify, send "reasoning": false unless the code uses the
returned explanation (it roughly doubles billed input tokens).scaledown-eval/ when the site is tuned. If it is
not, keep the template's TODO(scaledown): UNTUNED DRAFT marker in the code.Confirm: "Updated <file_path>"
After all edits, remind the user to set SCALEDOWN_API_KEY and get a free
key at https://scaledown.ai/dashboard (50M free tokens).
For each migrated call site, ask before spending tokens, then run one real request against
https://api.scaledown.ai with SCALEDOWN_API_KEY from the environment (never write the key to
disk), using the migrated code path or an equivalent curl. Confirm: HTTP 200, the result is where the
code reads it (tool_calls[0], top_label, parsed entities), and for image/PDF input that the
content-part shape was accepted. Report any 4xx/5xx with its body. Then list the sites that are
still Untuned.
get_scaledown_capabilities for limits and non-fits.What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
npx claudepluginhub scaledown-team/slm_agent --plugin slm-agentOther plugins' skills for the same job