Optimize Skill#
POST/v1/repos/{owner}/{repo}/optimize
Runs LLM-powered optimization on a SKILL.md file. Returns the original and optimized content with before/after quality scores. Rate limited to 5 requests per minute.
Path Parameters#
| Parameter | Type | Description |
|---|---|---|
| owner | string | GitHub username or organization |
| repo | string | Repository name |
Query Parameters#
| Parameter | Type | Description |
|---|---|---|
| path | string | Path to the skill directory or SKILL.md file |
Request Body#
Optional JSON body:
| Field | Type | Description |
|---|---|---|
| model | string? | LLM model override (default: server-configured) |
Response#
Returns original_content, optimized_content, original_score, optimized_score, original_failures, optimized_failures, and usage (token counts).
example response
{
"owner": "owner",
"repo": "repo",
"path": "skills/my-skill/SKILL.md",
"original_content": "---\nname: my-skill\n---\n...",
"optimized_content": "---\nname: my-skill\n---\n...",
"original_score": 72.5,
"optimized_score": 95.0,
"original_failures": 5,
"optimized_failures": 1,
"usage": { "model": "claude-haiku-4-5-20251001", "input_tokens": 2100, "output_tokens": 1800 }
}
This endpoint calls an LLM and may take 10-30 seconds to respond. Results are cached per commit SHA and model — repeated requests for the same skill on the same commit return the cached response.
Errors#
| Status | Cause |
|---|---|
| 404 | Repository or skill path not found |
| 422 | LLM generation failed |
| 429 | Rate limit exceeded |
| 503 | Service not configured (missing API key) |
| 504 | Operation timed out |
Example#
bash
curl -X POST "https://api.skill-lab.dev/v1/repos/owner/repo/optimize?path=my-skill"javascript
const res = await fetch("https://api.skill-lab.dev/v1/repos/owner/repo/optimize?path=my-skill", { method: "POST" });
const data = await res.json();
// data.optimized_scorepython
import httpx
res = httpx.post("https://api.skill-lab.dev/v1/repos/owner/repo/optimize?path=my-skill")
data = res.json()
# data['optimized_score']