Overview of the optimization lifecycle
Coolhand continuously identifies opportunities to improve prompt efficiency, reduce token expenditure, and prevent runtime errors across your AI workloads. When Coolhand determines that an action should be taken, it generates an optimization in the proposed state.
While you can review and search optimizations through the web dashboard or the query endpoint (see How do I list and search optimizations using the REST API?), engineering teams and autonomous coding agents can manage the complete lifecycle programmatically:
- Triage: Inspect proposed recommendations sorted by priority, complete with implementation briefs tailored for coding agents.
- Claim: Assign an open optimization to yourself or an agent to signal that work is underway.
- Complete: Mark the optimization as implemented once changes have landed, providing a description of the change and an optional pull request link.
- Dismiss or reopen: Reject recommendations that are not applicable with a standard reason code, or reopen previously dismissed recommendations if circumstances change.
Every endpoint and MCP tool requires your workspace's private API key.
Triaging proposed work
Before claiming an optimization, agents and developers can retrieve a curated, prioritized batch of open recommendations using the triage endpoint or tool. Unlike standard listing endpoints, the triage interface:
- Restricts results to
proposedrecommendations ready for action. - Orders items by
impact_complexityby default (highest impact first, followed by lowest complexity, with unrated items last). - Includes
agent_instructions: a targeted Markdown implementation brief explaining the problem, the required changes, and verification steps. - Omits bulky historical raw logs and diagnostic plans, capping inline briefs at 4,000 characters (flagged with
"truncated": true) so requests remain fast and compact.
Fetching a triage batch with the REST API
Send a GET request to /api/v2/optimizations/triage:
curl -H "Authorization: Bearer $COOLHAND_PRIVATE_API_KEY" \
"https://coolhandlabs.com/api/v2/optimizations/triage?repo=git@github.com:acme/backend.git&limit=10"
Query parameters
repo(optional): Git remote URL of the target repository (e.g.git@github.com:acme/backend.gitoracme/backend). Limits results to optimizations mapped to that repository.include_unmapped(optional, boolean): Whenrepois provided, setting this totruealso returns recommendations that have not yet been associated with any repository. This is useful when working in a repository without a source-control integration. Each item includes arepo_matchfield set to"mapped"or"unmapped".since(optional): An ISO 8601 date or timestamp (e.g.2026-11-01). Only optimizations proposed at or after this timestamp are returned.sort_by(optional):impact_complexity(default) orcreated_at_desc(newest first).perorlimit(optional): Number of records per page (default is 25, maximum is 50).page(optional): Page number to fetch (starts at 1).
Response headers
The response includes standard pagination headers (X-Page, X-Per-Page, X-Total-Count, X-Total-Pages) along with X-Unmapped-Count, which indicates how many total proposed recommendations across your workspace are not yet mapped to any repository.
Example response item:
[
{
"id": "opt_9f8a1c",
"title": "Migrate invoice extraction prompt to structured output schema",
"status": "proposed",
"category": "quality_improvement",
"impact": "high_impact",
"complexity": "low_complexity",
"optimization_type": "improvement",
"repo_match": "mapped",
"truncated": false,
"agent_instructions": "## Objective\nMigrate JSON output generation to native structured outputs..."
}
]
Triaging optimizations over MCP
When integrating Claude Code or another MCP-compliant assistant, call triage_optimizations:
{
"name": "triage_optimizations",
"arguments": {
"limit": 10,
"repo": "git@github.com:acme/backend.git",
"include_unmapped": true
}
}
The tool returns an array of matching optimizations, total count, unmapped count, and the active filters applied.
Claiming an optimization
Claiming an optimization announces to team members and other automated agents that an issue is being actively worked on.
Key transition rules:
- State requirement: The optimization must be in the
proposedstatus. Calling claim on a draft, completed, or dismissed item returns a422 Unprocessable Contenterror. - Takeover: Claiming an item that is already assigned to someone else succeeds and reassigns it to the caller.
- Refreshing the assignment: Calling claim again as the existing assignee keeps the current work item link (if omitted) and resets the assignment timestamp.
- Repository mapping: Providing a
repoparameter records that the optimization belongs to that repository.
Claiming with the REST API
Send a PATCH request to /api/v2/optimizations/:id:
curl -X PATCH \
-H "Authorization: Bearer $COOLHAND_PRIVATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transition": "claim",
"work_item_url": "https://github.com/acme/backend/issues/invoice-extraction",
"repo": "git@github.com:acme/backend.git"
}' \
"https://coolhandlabs.com/api/v2/optimizations/opt_9f8a1c"
The response returns the updated optimization containing the active assignment object:
{
"id": "opt_9f8a1c",
"title": "Migrate invoice extraction prompt to structured output schema",
"status": "proposed",
"assignment": {
"assigned_to": {
"name": "Alex Chen",
"type": "user"
},
"assigned_at": "2026-11-04T14:30:00Z",
"days_ago": 0,
"stale": false,
"work_item_url": "https://github.com/acme/backend/issues/invoice-extraction"
}
}
Claiming over MCP
In MCP environments, invoke claim_optimization:
{
"name": "claim_optimization",
"arguments": {
"id": "opt_9f8a1c",
"work_item_url": "https://github.com/acme/backend/issues/invoice-extraction",
"repo": "git@github.com:acme/backend.git"
}
}
Understanding assignment staleness
An assignment is an advisory signal, not an immutable lock. If an optimization remains assigned and uncompleted for 7 days or more, Coolhand marks "stale": true within the assignment payload.
When triaging, if you or an agent encounter a stale assignment:
- Check the URL provided in
work_item_urlto see if an open pull request or issue exists and is still being worked on. - If the work was abandoned, you can safely claim the optimization to take over, or dismiss it if the recommendation is no longer relevant.
Completing an optimization
When an optimization's changes have been implemented in your codebase or prompt configuration, transition it to completed.
Key transition rules:
- State requirement: The optimization must be in the
proposedstatus. - Implementation note: A descriptive
note(up to 5,000 characters) detailing what was changed and where is required. - Pull request link: An optional
pr_urlparameter records the link to the merged or open pull request. - Resolution attribution: The optimization records who completed it and stamps completion status as fixed by client.
- Idempotency: Submitting a completion on an optimization already marked completed as fixed by client is a safe no-op.
Completing with the REST API
Send a PATCH request with transition: "complete":
curl -X PATCH \
-H "Authorization: Bearer $COOLHAND_PRIVATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transition": "complete",
"note": "Updated prompt template to use structured outputs and validated against invoice fixtures.",
"pr_url": "https://github.com/acme/backend/pull/invoice-extraction",
"repo": "git@github.com:acme/backend.git"
}' \
"https://coolhandlabs.com/api/v2/optimizations/opt_9f8a1c"
The response includes the updated status: "completed", completion_note, completed_by, and work_item_url.
Completing over MCP
To complete an item over MCP, invoke complete_optimization:
{
"name": "complete_optimization",
"arguments": {
"id": "opt_9f8a1c",
"note": "Updated prompt template to use structured outputs and validated against invoice fixtures.",
"pr_url": "https://github.com/acme/backend/pull/invoice-extraction",
"repo": "git@github.com:acme/backend.git"
}
}
Dismissing an optimization
If a recommendation is not feasible, does not fit your system architecture, or is already addressed, you can dismiss it.
Key transition rules:
- State requirement: The optimization must be in the
proposedstatus. - Reason code: You must supply one of the predefined
reason_codevalues listed below. - Explanation: An optional free-text explanation can be supplied alongside the reason code.
- Repository rejection: If you pass
repowithreason_code: "not_relevant", the optimization is flagged as rejected for that repository specifically and will not appear in subsequent triage calls for that repo.
Dismissal reason codes
Every dismissal must include one of the following reason codes:
| Reason code | Description |
|---|---|
not_relevant |
The suggested change does not apply to this workload, repository, or architecture. |
already_done |
The issue was already resolved in an unlinked commit, refactor, or external service. |
wrong_analysis |
The diagnostic analysis or root cause diagnosis is inaccurate. |
insufficient_context |
The recommendation lacks enough contextual data to execute safely. |
too_risky |
The change introduces unacceptable reliability, security, or migration risk. |
not_now |
The proposal is valid but deprioritized or postponed for a future roadmap cycle. |
other |
The rationale falls outside standard categories (provide details in explanation). |
Dismissing with the REST API
Send a PATCH request with transition: "dismiss":
curl -X PATCH \
-H "Authorization: Bearer $COOLHAND_PRIVATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transition": "dismiss",
"reason_code": "already_done",
"explanation": "Refactored invoice extraction to use an internal validation service last week."
}' \
"https://coolhandlabs.com/api/v2/optimizations/opt_9f8a1c"
Closing over MCP
In MCP environments, invoke close_optimization:
{
"name": "close_optimization",
"arguments": {
"id": "opt_9f8a1c",
"reason_code": "already_done",
"explanation": "Refactored invoice extraction to use an internal validation service last week."
}
}
Note: If close_optimization is invoked on an item that has already been dismissed (for instance, by a concurrent sweep or teammate), the tool returns a successful response with "already_dismissed": true rather than an unrecoverable error.
Reopening a dismissed optimization
If circumstances change—such as a recurring prompt failure or new evidence showing that a dismissed recommendation is relevant after all—you can reopen it.
Key transition rules:
- State requirement: The optimization must be currently in the
dismissedstatus. Attempting to reopen a proposed or completed item returns an error. - Reopen target: Reopening transitions the optimization back to
draftfor review. - Clean slate: Returning to draft clears any stale assignment, work item links, or review notes from the prior cycle, giving the recommendation a fresh review loop.
- Explanation required: An explanation describing why the original dismissal reason no longer applies is required.
Reopening with the REST API
Send a PATCH request with transition: "reopen":
curl -X PATCH \
-H "Authorization: Bearer $COOLHAND_PRIVATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transition": "reopen",
"explanation": "The fallback parser failed again on multi-page invoices; we need the structured outputs schema change after all."
}' \
"https://coolhandlabs.com/api/v2/optimizations/opt_9f8a1c"
The response confirms the record has returned to status: "draft" and includes reopen_explanation and reopened_at.
Reopening over MCP
In MCP environments, invoke reopen_optimization:
{
"name": "reopen_optimization",
"arguments": {
"id": "opt_9f8a1c",
"explanation": "The fallback parser failed again on multi-page invoices; we need the structured outputs schema change after all."
}
}
After reopening an optimization, agents can investigate the draft and revise its details before proposing it again.
Fetching full optimization details
When an optimization's brief is truncated during triage ("truncated": true), or when you need complete diagnostic analysis and change suggestions:
- REST API: Call
GET /api/v2/optimizations/:id. When the optimization isproposed, this endpoint returns the complete, un-truncatedagent_instructions. - MCP: Call
get_optimizationwith the optimizationidto receive the full record.