agentleFS
AtmoskunAtmoskun/claude-skills/skills/prompt-optimizer/SKILL.md

prompt-optimizer

Skill0 starsChanged 9 months agoMITView on GitHub

Iteratively optimize a prompt using PromptSpec + tests + versioning + Gemini reviewer. Use only when the user explicitly wants prompt iteration with tracked versions and test feedback.

79 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use agent-architecture-audit, continuous-agent-loop and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ronmkrSkill

    agent-architecture-audit

    Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature.

    Also in 3 projects that use this

  • junimnjwSkill

    continuous-agent-loop

    Patterns for continuous autonomous agent loops with quality gates, evals, and recovery controls.

    Also in 3 projects that use this

  • junimnjwSkill

    agent-harness-construction

    Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates.

    Also in 3 projects that use this

  • get-proofpilotSkill

    context-budget

    Audits Claude Code context window consumption across agents, skills, MCP servers, and rules. Identifies bloat, redundant components, and produces prioritized token-savings recommendations.

    Also in 5 projects that use this

  • LangChainSkill

    docker-patterns

    Best practices for Docker containerization and multi-stage builds

    Also in 4 projects that use this

  • royaluniondesign-sysSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 64 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    TestSuite: Test cases with expected output characteristics

    line 10
  2. Distinctive:

    Only stores: inputs, Gemini output, versions, user feedback

    line 189

“Common” is measured: kept by at least 6 in 10 of the 64 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Prompt Optimizer

Iteratively optimize prompts through:

  • PromptSpec: Define requirements, constraints, and evaluation criteria
  • TestSuite: Test cases with expected output characteristics
  • Versioning: Track all prompt iterations
  • Gemini Review: Structured feedback with PASS/FAIL verdict, issues, and minimal patches
  • User Testing: User-driven testing is MANDATORY before each iteration

Workflow

┌─────────────────────────────────────────────────────────────────┐
│  1. 创建 Session  →  2. 填写 Spec  →  3. Claude 生成初版        │
└─────────────────────────────────────────────────────────────────┘
                              │
                              ▼
                    ┌─────────────────┐
                    │  4. Gemini 审阅  │
                    │  (理论层面检查)   │
                    └────────┬────────┘
                             │
                             ▼
              ┌──────────────────────────────┐
              │  5. 用户测试 (必须!用户主导)  │
              │  → 用真实数据测试 prompt       │
              │  → 记录实际效果和问题          │
              └──────────────┬───────────────┘
                             │
                             ▼
                      ┌────────────┐
                      │  满意?     │
                      └─────┬──────┘
                            │
                 ┌──────────┴──────────┐
                 │                     │
                YES                    NO
                 │                     │
                 ▼                     ▼
          ┌───────────┐    ┌─────────────────────┐
          │ 6. 完成   │    │ 6. 记录反馈 + 迭代   │
          │ Finalize  │    │ → 回到第4步          │
          └───────────┘    └─────────────────────┘

核心原则:用户测试 > Gemini 审阅

  • Gemini 审阅是"理论层面"的检查(格式、逻辑、约束)
  • 用户测试是"实战层面"的验证(真实数据、实际效果)
  • 只有用户说"好"才算好,Gemini 的 PASS 只是参考

Step-by-Step

1. Create Session

python ~/.claude/skills/prompt-optimizer/scripts/run.py optimizer.py new --goal "USER'S GOAL"

2. Fill PromptSpec

Edit data/sessions/{id}/spec.md to define:

  • Task description (one sentence)
  • Input/output format
  • Hard constraints (must satisfy)
  • Soft constraints (try to satisfy)
  • Things to avoid
  • Evaluation criteria

3. Create Initial Prompt (Claude)

echo "PROMPT_TEXT" | python ~/.claude/skills/prompt-optimizer/scripts/run.py optimizer.py add-version --session ID --source claude

4. Gemini Review (理论检查)

python ~/.claude/skills/prompt-optimizer/scripts/run.py optimizer.py review --session ID

Gemini returns:

  • Verdict: PASS / FAIL
  • Top 5 Issues: Problem → severity → trigger scenario → verification
  • Minimal Patch: Replace/add/delete instructions (not full rewrite)
  • Regression Risks: Potential new issues from changes

5. User Testing (必须!用户主导)

这是最关键的一步。用户必须:

  1. 用真实数据测试当前版本的 prompt
  2. 观察实际输出效果
  3. 记录问题和改进建议
python ~/.claude/skills/prompt-optimizer/scripts/run.py optimizer.py feedback --session ID --text "USER'S FEEDBACK"

反馈应包含:

  • 测试了什么数据?
  • 实际输出是什么?
  • 哪里不符合预期?
  • 需要怎么改?

6. Iterate or Finalize

如果用户不满意:

  1. Claude 根据用户反馈 + Gemini 建议修改 prompt
  2. 保存新版本
  3. 回到第 4 步

如果用户满意:

python ~/.claude/skills/prompt-optimizer/scripts/run.py optimizer.py finalize --session ID

Commands

CommandDescription
configure --api-key KEYSet Gemini API key
statusCheck API and session stats
new --goal "..."Create new session
listList all sessions
show --session IDShow session details
add-version --session IDAdd prompt version
review --session IDGet Gemini review
feedback --session ID --text "..."Record user test feedback (必须)
diff --session ID --v1 NCompare versions
finalize --session IDComplete session

Data Structure

data/sessions/{session_id}/
├── state.json           # Session metadata
├── spec.md              # PromptSpec (requirements)
├── tests/               # Test cases
│   ├── case_001.md
│   └── ...
├── versions/            # Prompt versions
│   ├── manifest.json
│   ├── v1.md
│   └── v2.md
└── conversations/       # Review rounds + user feedback
    ├── round_001.json   # 包含 gemini_review + user_feedback
    └── ...

Example Session

User: 帮我优化一个分析财报的 prompt

Claude: 创建优化 session...
[Creates session, fills spec.md]
[生成初版 prompt v1]
让我请 Gemini 审阅...

[Gemini Review - Round 1]
Verdict: FAIL
Issues: 缺少输出格式定义...

Claude: 根据 Gemini 建议修改,保存为 v2。
请你用真实财报数据测试一下这个 prompt。

User: 我测试了腾讯 2024Q3 财报,发现:
1. 输出的表格格式不对
2. 没有提取研发费用
3. 投资建议太模糊

Claude: 收到!根据你的反馈修改:
1. 修正表格格式
2. 添加研发费用到关键指标
3. 投资建议增加具体理由要求
保存为 v3...

[继续迭代]

User: 这次测试效果很好,可以用了

Claude: [finalize session]
最终 prompt 为 v4,经过 3 轮迭代。

Notes

  • 用户反馈优先级最高 - Gemini 只是辅助,用户说了算
  • Only stores: inputs, Gemini output, versions, user feedback
  • Gemini acts as "strict reviewer" - conservative, specific, testable suggestions
  • Each iteration MUST include user testing before proceeding

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.