跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
浏览器与自动化

enhance-prompts

Use when improving general prompts for structure, examples, and constraints.

agent-sh · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add agent-sh/agentsys --skill enhance-prompts

技能说明


name: enhance-prompts description: "Use when improving general prompts for structure, examples, and constraints." version: 5.1.0 argument-hint: "[path] [--fix]"

enhance-prompts

Analyze prompts for clarity, structure, examples, and output reliability.

Parse Arguments

const args = '$ARGUMENTS'.split(' ').filter(Boolean);
const targetPath = args.find(a => !a.startsWith('--')) || '.';
const fix = args.includes('--fix');

Differentiation from enhance-agent-prompts

SkillFocusUse When
enhance-promptsPrompt quality (clarity, structure, examples)General prompts, system prompts, templates
enhance-agent-promptsAgent config (frontmatter, tools, model)Agent files with YAML frontmatter

Workflow

  1. Run Analyzer - Execute the JavaScript analyzer to get findings:

    node -e "const a = require('./lib/enhance/prompt-analyzer.js'); console.log(JSON.stringify(a.analyzeAllPrompts('.'), null, 2));"
    

    For a specific path: a.analyzeAllPrompts('./plugins/enhance') For a single file: a.analyzePrompt('./path/to/file.md')

  2. Parse Results - The analyzer returns JSON with summary and findings

  3. Filter - Apply certainty filtering based on --verbose flag

  4. Report - Format findings as markdown output

  5. Fix - If --fix flag, apply auto-fixes from findings

The JavaScript analyzer (lib/enhance/prompt-analyzer.js) implements all detection patterns including AST-based code validation. The patterns below are reference documentation.


Prompt Engineering Knowledge Reference

System Prompt Structure

Effective system prompts include: Role/Identity, Capabilities & Constraints, Instruction Priority, Output Format, Behavioral Directives, Examples, Error Handling.

Minimal Template:

<system>
You are [ROLE]. [PURPOSE].
Key constraints: [CONSTRAINTS]
Output format: [FORMAT]
When uncertain: [HANDLING]
</system>

XML Tags (Claude-Specific)

Claude is fine-tuned for XML tags. Use: <role>, <constraints>, <output_format>, <examples>, <instructions>, <context>

<constraints>
- Maximum response length: 500 words
- Use only Python 3.10+ syntax
</constraints>

Few-Shot Examples

  • 2-5 examples is optimal (research-backed)
  • Include edge cases and ensure format consistency
  • Start zero-shot, add examples only if needed
  • Show both good AND bad examples when relevant

Chain-of-Thought (CoT)

Use CoTDon't Use CoT
Complex multi-step reasoningSimple factual questions
Math and logic problemsClassification tasks
Code debuggingWhen model has built-in reasoning

Key: Modern models (Claude 4.x, o1/o3) perform CoT internally. "Think step by step" is redundant.

Role Prompting

Helps: Creative tasks, tone/style, roleplay Doesn't help: Accuracy tasks, factual retrieval, complex reasoning

Better: "Approach systematically, showing work" vs "You are an expert"

Instruction Hierarchy

Priority: System > Developer > User > Retrieved Content

Include explicit priority in prompts with multiple constraint sources.

Negative Prompting

Positive alternatives are more effective than negatives:

Less EffectiveMore Effective
"Don't use markdown""Use prose paragraphs"
"Don't be vague""Use specific language"

Structured Output

  • Prompt-based: ~35.9% reliability
  • Schema enforcement: 100% reliability
  • Always provide schema example and validate output

Context Window Optimization

Lost-in-the-Middle: Models weigh beginning and end more heavily.

Place critical constraints at start, examples in middle, error handling at end.

Extended Thinking

High-level instructions ("Think deeply") outperform step-by-step guidance. "Think step-by-step" is redundant with modern models.

Anti-Patterns Quick Reference

Anti-PatternProblemFix
Vague references"The above code" loses contextQuote specifically
Negative-only"Don't do X" without alternativeState what TO do
Aggressive emphasis"CRITICAL: MUST"Use normal language
Redundant CoTWastes tokensLet model manage
Critical info buriedLost-in-the-middlePlace at start/end

Detection Patterns

1. Clarity Issues (HIGH Certainty)

Vague Instructions: "usually", "sometimes", "try to", "if possible", "might", "could"

Negative-Only Constraints: "don't", "never", "avoid" without stating what TO do

Aggressive Emphasis: Excessive CAPS (CRITICAL, IMPORTANT), multiple !!

2. Structure Issues (HIGH/MEDIUM Certainty)

Missing XML Structure: Complex prompts (>800 tokens) without XML tags

Inconsistent Sections: Mixed heading styles, skipped levels (H1→H3)

Critical Info Buried: Important instructions in middle 40%, constraints after examples

3. Example Issues (HIGH/MEDIUM Certainty)

Missing Examples: Complex tasks without few-shot, format requests without example

Suboptimal Count: Only 1 example (optimal: 2-5), more than 7 (bloat)

Missing Contrast: No good/bad labeling, no edge cases

4. Context Issues (MEDIUM Certainty)

Missing WHY: Rules without explanation

Missing Priority: Multiple constraint sections without conflict resolution

5. Output Format Issues (HIGH/MEDIUM Certainty)

Missing Format: Substantial prompts without format specification

JSON Without Schema: Requests JSON but no example structure

6. Anti-Patterns (HIGH/MEDIUM/LOW Certainty)

Redundant CoT (HIGH): "Think step by step" with modern models

Overly Prescriptive (MEDIUM): 10+ numbered steps, micro-managing reasoning

Prompt Bloat (LOW): Over 2500 tokens, redundant instructions

Vague References (HIGH): "The above code", "as mentioned"


Auto-Fix Implementations

1. Aggressive Emphasis

Replace CRITICAL→

阅读完整来源 ↗