Agent Skills › trycompai/comp › prompt-engineering

prompt-engineering

GitHub

提供提示词工程最佳实践,涵盖核心原则与六大技巧,指导用户通过清晰指令、示例及思维链提升大模型交互效果。

.agents/skills/prompt-engineering/SKILL.md trycompai/comp

Trigger Scenarios

询问如何优化提示词 需要生成高质量Prompt模板 探讨提示词设计策略

Install

npx skills add trycompai/comp --skill prompt-engineering -g -y
More Options

Non-standard path

npx skills add https://github.com/trycompai/comp/tree/main/.agents/skills/prompt-engineering -g -y

Use without installing

npx skills use trycompai/comp@prompt-engineering

指定 Agent (Claude Code)

npx skills add trycompai/comp --skill prompt-engineering -a claude-code -g -y

安装 repo 全部 skill

npx skills add trycompai/comp --all -g -y

预览 repo 内 skill

npx skills add trycompai/comp --list

SKILL.md

Frontmatter
{
    "name": "prompt-engineering",
    "description": "Prompt engineering best practices - invoke with @prompt-engineering"
}

Source Cursor rule: .cursor/rules/prompt-engineering.mdc. Original file scope: .cursor/rules/*.mdc. Original Cursor alwaysApply: false.

Prompt Engineering Best Practices

Based on Claude's Prompt Engineering Documentation

Core Principles

1. Define Success Criteria First

Before writing prompts:

  • Establish clear objectives: What constitutes a successful response?
  • Create evaluation metrics: How will you measure prompt effectiveness?
  • Draft and iterate: Start with a first draft and refine based on results

2. When to Use Prompt Engineering vs Fine-tuning

Prompt engineering is preferred because:

  • Resource efficient: Only requires text input, no GPUs
  • Cost effective: Uses base model pricing
  • Maintains updates: Works across model versions
  • Time saving: Instant results vs hours/days for fine-tuning
  • Minimal data needs: Works with zero-shot or few-shot
  • Flexible iteration: Quick experimentation cycle
  • Preserves knowledge: No catastrophic forgetting
  • Transparent: Human-readable, easy to debug

The 6 Core Techniques

1. Be Clear and Direct

Principle: Provide explicit, unambiguous instructions.

❌ Bad: "Tell me about it"
✅ Good: "Summarize the following article in three bullet points, focusing on key findings"

❌ Bad: "Help with code"
✅ Good: "Debug this Python function that should return the sum of even numbers in a list"

Tips:

  • State the task explicitly at the start
  • Specify the desired output format (bullet points, JSON, paragraphs)
  • Include constraints (word count, tone, audience)
  • Mention what to include AND what to exclude

2. Use Examples (Multishot Prompting)

Principle: Show the model what you want through examples.

<examples>
  <example>
    <input>The movie was absolutely terrible, waste of time</input>
    <output>{"sentiment": "negative", "confidence": 0.95}</output>
  </example>
  <example>
    <input>Decent film, not great but watchable</input>
    <output>{"sentiment": "neutral", "confidence": 0.7}</output>
  </example>
  <example>
    <input>Best movie I've seen this year!</input>
    <output>{"sentiment": "positive", "confidence": 0.9}</output>
  </example>
</examples>

Now analyze: "The special effects were amazing but the plot was confusing"

Tips:

  • Include 3-5 diverse examples covering edge cases
  • Show examples of BOTH good and bad outputs
  • Match example complexity to your actual use case
  • Order examples from simple to complex

3. Let Claude Think (Chain of Thought)

Principle: Encourage step-by-step reasoning for complex tasks.

<instruction>
Solve this problem step by step. Show your reasoning before giving the final answer.
</instruction>

<problem>
A train leaves Station A at 9:00 AM traveling at 60 mph. Another train leaves
Station B at 10:00 AM traveling at 80 mph toward Station A. The stations are
280 miles apart. When will the trains meet?
</problem>

<thinking>
[Let Claude work through the problem here]
</thinking>

<answer>
[Final answer after reasoning]
</answer>

Tips:

  • Use phrases like "Think step by step" or "Explain your reasoning"
  • For complex tasks, explicitly request a thinking section
  • Chain of thought improves accuracy on math, logic, and multi-step problems
  • Can use <thinking> tags to separate reasoning from output

4. Use XML Tags

Principle: Structure prompts with clear delimiters for better parsing.

<context>
You are helping debug a penetration testing tool that automates security scans.
</context>

<task>
Analyze the following error log and identify the root cause.
</task>

<error_log>
[2024-01-15 10:23:45] ERROR: Connection timeout after 30s
[2024-01-15 10:23:45] DEBUG: Target: 192.168.1.1:443
[2024-01-15 10:23:45] DEBUG: Retry attempt 3 of 3
</error_log>

<output_format>
Provide your analysis in this format:
- Root cause: [one sentence]
- Evidence: [relevant log lines]
- Recommended fix: [actionable steps]
</output_format>

Common XML Tags:

  • <context> - Background information
  • <task> or <instruction> - What to do
  • <examples> - Sample inputs/outputs
  • <constraints> - Limitations or rules
  • <output_format> - Expected response structure
  • <thinking> - Reasoning section
  • <answer> - Final response

5. Give Claude a Role (System Prompts)

Principle: Assign a persona to influence response style and expertise.

<role>
You are a senior security researcher with 15 years of experience in penetration
testing. You specialize in web application security and have discovered multiple
CVEs. You communicate findings clearly and prioritize actionable recommendations.
</role>

<task>
Review this HTTP response and identify potential security vulnerabilities.
</task>

Effective Role Elements:

  • Expertise level (senior, expert, specialist)
  • Domain knowledge (security, finance, medicine)
  • Communication style (technical, friendly, formal)
  • Priorities (accuracy, brevity, thoroughness)

6. Prefill Claude's Response

Principle: Start the response to guide format and direction.

Human: List the top 3 security vulnerabilities in this code.

Version History

  • 0ccfcc2 Current 2026-09-27 10:23

Same Skill Collection

.agents/skills/audit-design-system/SKILL.md
.agents/skills/audit-hooks/SKILL.md
.agents/skills/audit-rbac/SKILL.md
.agents/skills/audit-tests/SKILL.md
.agents/skills/better-auth-best-practices/SKILL.md
.agents/skills/billing/SKILL.md
.agents/skills/code/SKILL.md
.agents/skills/cursor-usage/SKILL.md
.agents/skills/data/SKILL.md
.agents/skills/diagnose-generation-failure/SKILL.md
.agents/skills/forms/SKILL.md
.agents/skills/generate-mcp-server/SKILL.md
.agents/skills/infra/SKILL.md
.agents/skills/manage-openapi-overlays/SKILL.md
.agents/skills/new-feature-setup/SKILL.md
.agents/skills/production-readiness/SKILL.md
.agents/skills/speakeasy-context/SKILL.md
.agents/skills/stale-worktree-cleanup/SKILL.md
.agents/skills/trigger-advanced-tasks/SKILL.md
.agents/skills/trigger-basic/SKILL.md
.agents/skills/trigger-config/SKILL.md
.agents/skills/trigger-realtime/SKILL.md
.agents/skills/ui/SKILL.md
.claude/skills/api-endpoint-contract/SKILL.md
.claude/skills/audit-design-system/SKILL.md
.claude/skills/audit-hooks/SKILL.md
.claude/skills/audit-rbac/SKILL.md
.claude/skills/audit-tests/SKILL.md
.claude/skills/check-results-service/SKILL.md
.claude/skills/cleanup/SKILL.md
.claude/skills/code/SKILL.md
.claude/skills/cursor-usage/SKILL.md
.claude/skills/data/SKILL.md
.claude/skills/forms/SKILL.md
.claude/skills/infra/SKILL.md
.claude/skills/new-feature-setup/SKILL.md
.claude/skills/production-readiness/SKILL.md
.claude/skills/prompt-engineering/SKILL.md
.claude/skills/security-review/SKILL.md
.claude/skills/stale-worktree-cleanup/SKILL.md
.claude/skills/trigger-advanced-tasks/SKILL.md
.claude/skills/trigger-basic/SKILL.md
.claude/skills/trigger-config/SKILL.md
.claude/skills/trigger-realtime/SKILL.md
.claude/skills/ui/SKILL.md
.agents/skills/essentials/SKILL.md
.agents/skills/prisma/SKILL.md
.agents/skills/trigger-scheduled-tasks/SKILL.md
.claude/skills/essentials/SKILL.md

Metadata

Files
0
Version
0ccfcc2
Hash
a75dad39
Indexed
2026-09-27 10:23

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-27 17:32
浙ICP备14020137号-1