SuperAPI AI Directory

better-prompt

Writing & research

View repository

Updated 10-15 22:14

About this skill

Better Prompt - Prompt Optimizer

BenszAPI Task Workspace

New task intermediate files for this Skill are uniformly written to ./.bensz-api/task-{yyyymmdd-hhmm}-{简短描述}/{skill名}/input|output|log/. The same task reuses one task root directory; only multi-Skill collaboration creates shared/. Official deliverables are not written to this directory; historical hidden directories only allow explicit compatible reading, migration, or cleanup.

Collaboration Agreement with bensz-collect-bugs

  • For bugs caused by design flaws in this skill, first use bensz-collect-bugs to record them in a standardized way to ~/.bensz-skills/bugs/, do not directly modify the user's locally installed skill source code; if there is a workaround, record the bug first, then continue completing the task.
  • Only when the user explicitly requests public reporting such as "report bensz skills bugs", use the local gh to upload the newly added bug to huangwb8/bensz-bugs; do not pull / clone the entire repository.

Optimize crude prompts into high-quality versions that conform to community best practices.

Version and Compatibility

  • Applicable to: mainstream LLMs such as Claude 3.x/4.x, GPT-4/5, Gemini, etc.
  • Best-practice sources: OpenAI/Anthropic official documentation (2026-02)
  • Update strategy: revise in sync when the official documentation has major updates

Inapplicable Scenarios

The following situations are not recommended for using this skill:

  • The prompt has already been professionally optimized (score >= 8/10)
  • Only diagnosis of problems is needed, no modification suggestions are needed
  • Extra-long prompts (>10000 characters) require professional splitting
  • The user explicitly requests keeping the original style

Input Requirements

The user provides an original prompt to be optimized (it can be a crude version in any form).

Optimization Framework

Based on the official best practices of OpenAI and Anthropic , a five-dimension optimization framework is adopted:

Dimension Checkpoint Priority
Clarity Are the instructions clear? Is there any ambiguity? P0
Completeness Is necessary information missing? Is the context sufficient? P0
Structure Are Markdown/XML tags used to organize content? P1
Exemplification Are input/output examples provided (few-shot)? P2
Constraint Are boundaries clearly defined (what to do / what not to do)? P2

Note: P0/P1/P2 in the table above indicate the "importance priority of optimization dimensions", which have the same meaning as the dimensions values (1-5) in config.yaml: P0=5 (highest priority), P1=4, P2=3.

Optimization Workflow

Step 0: Input Validation (Pre-check)

Validate the validity of the user input:

Input State Judgment Criteria Handling Method
Empty input Character count = 0 Reject, prompt "please provide the prompt to be optimized"
Too short Character count < 10 Prompt "prompt is too short, please provide more context"
Completed Score ≥ 8/10 Prompt "prompt is sufficiently complete, does it still need optimization?", waiting for user confirmation
Valid Verification passed Continue Step 1

Step 1: Analyze the original prompt

Identify the prompt's:

  • Core task: What does the user want the AI to do?
  • Missing elements: Which key information is missing?
  • Room for improvement: Which areas can be optimized?

Step 2: Determine model type adaptation

Determine the target model type based on task characteristics:

Model type Applicable scenarios Optimization strategy
GPT model Precise execution, formatted output, code generation Provide detailed steps and clear logic
Reasoning model Complex reasoning, multi-step planning, open-ended tasks Give high-level goals and preserve flexibility

If the user does not specify, default to the GPT model optimization strategy (more precise).

Step 3: Apply the optimization template

Below is the standard structural template for the optimized prompt:

# Identity(身份定义)
[描述 AI 的角色、专业领域、沟通风格]

# Instructions(核心指令)
[明确的任务说明]
- 规则 1
- 规则 2
- 约束条件(不做什么)

# Examples(示例)
<example id="1">
<input>示例输入</input>
<output>示例输出</output>
</example>

# Context(上下文)
[任务相关的背景信息、参考资料]

Rules for using Examples:

  • For complex tasks (complexity ≥ 3/5), Examples arerequired
  • For simple tasks, Examples can be omitted
  • If the original prompt already has examples, they should be retained or enhanced during optimization

Step 4: Output the optimization results

The output contains three parts (all included by default, adjustable via config.yaml):

  1. Optimization analysis: Briefly explain what improvements were made
  2. Optimized prompt: A high-quality version that follows best practices
  3. Usage suggestions: Adjustment suggestions for specific scenarios

Output format

## 优化分析

| 维度 | 原始状态 | 优化措施 |
|------|---------|---------|
| 清晰度 | ... | ... |
| 完整性 | ... | ... |
| 结构化 | ... | ... |
| 示例性 | ... | ... |
| 约束性 | ... | ... |

## 优化后的 Prompt

# Identity
...

# Instructions
...

# Examples(如适用)
...

# Context(如适用)
...

## 使用建议

- 适用于:[模型类型/场景]
- 调整建议:[如需针对特定场景调整的建议]

Optimization effect evaluation

Compare and evaluate the prompt before and after optimization:

Dimension Score before optimization Score after optimization Improvement description
Clarity x/5 x/5 ...
Completeness x/5 x/5 ...
Structure x/5 x/5 ...
Examples x/5 x/5 ...
Constraints x/5 x/5 ...
Total score xx/25 xx/25 +xx

Scoring criteria: 1=very poor, 2=poor, 3=average, 4=good, 5=excellent

Quality standards

The optimized prompt must satisfy:

Standard Requirement
Clarity The core task can be stated clearly in one sentence
Executability The AI can directly understand and execute it
Completeness No necessary information is missing
Structure Clearly organized using Markdown/XML
Testability It can be determined whether the output meets expectations

Special scenario handling

According to the templates configurations have specific optimization priorities for different scenarios:

Code generation prompts

Configuration reference:config.yaml:templates.code_generation.focus_areas

Additional focus:

  • Clearly specify the programming language and framework
  • Specify code style conventions
  • Explain error handling requirements
  • Provide boundary condition examples

Text analysis prompts

Configuration reference:config.yaml:templates.text_analysis.focus_areas

Additional focus:

  • Clearly specify the output format (JSON/table/summary)
  • Define analysis dimensions and criteria
  • Provide classification/evaluation examples

Creative writing prompts

Configuration reference:config.yaml:templates.creative_writing.focus_areas

Additional focus:

  • Define style and tone
  • Explain the target audience
  • Provide reference examples
  • Set length constraints

Multi-turn dialogue prompts

Configuration reference:config.yaml:templates.multi_turn_conversation.focus_areas

Additional focus:

  • Define dialogue roles and boundaries
  • Explain state management requirements
  • Provide exception handling rules

Reference materials

For more detailed best practices, refer to references/prompt-engineering-best-practices.md