prompt-optimization
This skill automatically repeats prompts sent to Claude Haiku agents to improve accuracy on structured tasks like unit testing, linting, parsing, and list operations. Activate it when using Haiku models for deterministic work where accuracy matters more than latency, as the repetition occurs during the prefill stage without increasing generation time.
git clone --depth 1 https://github.com/asklokesh/loki-mode /tmp/prompt-optimization && cp -r /tmp/prompt-optimization/agent-skills/prompt-optimization ~/.claude/skills/prompt-optimizationSKILL.md
# Prompt Optimization Skill ## Overview Automatically applies prompt repetition for Haiku agents to improve accuracy by 4-5x on structured tasks. **Research Source:** "Prompt Repetition Improves Non-Reasoning LLMs" (arXiv 2512.14982v1) --- ## When to Activate This skill activates automatically for: - **Haiku agents** executing structured tasks - **Unit test execution** - **Linting and formatting** - **Parsing and extraction** - **List operations** (find, filter, count) --- ## How It Works ``` BEFORE: prompt = "Run unit tests in tests/ directory" AFTER (with skill): prompt = "Run unit tests in tests/ directory\n\nRun unit tests in tests/ directory" ``` The repeated prompt enables bidirectional attention within the parallelizable prefill stage, improving accuracy without latency penalty. --- ## Performance Impact | Task Type | Without Skill | With Skill | Improvement | |-----------|---------------|------------|-------------| | Unit tests | 65% accuracy | 95% accuracy | +46% | | Linting | 72% accuracy | 98% accuracy | +36% | | Parsing | 58% accuracy | 94% accuracy | +62% | **Latency:** Zero impact (occurs in prefill, not generation) --- ## Configuration ### Enable/Disable ```bash # Enabled by default for Haiku agents LOKI_PROMPT_REPETITION=true # Disable if needed LOKI_PROMPT_REPETITION=false ``` ### Repetition Count ```bash # 2x repetition (default) LOKI_PROMPT_REPETITION_COUNT=2 # 3x repetition (for position-critical tasks) LOKI_PROMPT_REPETITION_COUNT=3 ``` --- ## Agent Instructions When you are a **Haiku agent** and the task involves: - Running tests - Executing linters - Parsing structured data - Finding items in lists - Counting or filtering Your prompt will be automatically repeated 2x to improve accuracy. No action needed from you. If you are an **Opus or Sonnet agent**, this skill does NOT apply (reasoning models see no benefit from repetition). --- ## Metrics Track prompt optimization impact: ``` .loki/metrics/prompt-optimization/ ├── accuracy-improvement.json └── cost-benefit.json ``` --- ## References See `references/prompt-repetition.md` for full documentation. --- **Version:** 1.0.0
Interrogate a spec with Loki's Devil's-Advocate grill before building, and summarize the hardest questions it surfaces.
Check whether the spec has drifted from its lock using Loki's living-spec drift detection, and summarize the report.
Run Loki's deterministic PR verification on the current change and summarize the evidence verdict.
Launch Loki Mode autonomous SDLC agent. Handles PRD-to-deployment with minimal human intervention. Invoke for multi-phase development tasks, bug fixing campaigns, or full product builds.
Pause for review every N tasks - selective autonomy pattern