Skip to content
cccskills
FreePublished on GitHub

prompt-engineering

Design clearer prompts for AI tasks by setting success criteria, specifying output formats, adding examples, organizing context with XML tags, and assigning a role. The guidance helps you draft and refine instructions for more consistent responses.

OriginalShow the original description

Prompt engineering best practices - invoke with @prompt-engineering

trycompai/comp2,061 stars(GitHub 2,061 + cccskills 0)

Run score Not tested

See how to install

Good for

  • Clarifying instructions and expected output for a task
  • Adding examples to guide classification or formatting
  • Structuring context and constraints with XML tags
  • Assigning a role and tone for a response

Files included (1)

  • SKILL.md5.3 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

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.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Guide API endpoint changes so request DTOs, runtime validation, OpenAPI documentation, and MCP tool metadata stay aligned. It covers discoverability, authentication, uploads, long-running tasks, and response types that MCP tools cannot handle.

  • Adding an API endpoint with a request body
  • Updating DTO validation and OpenAPI metadata
  • Making an endpoint available as an MCP tool
trycompai/comp2.1KUpdated Oct 24, 2026

Review specified files for design system usage, replace legacy @trycompai/ui components and lucide-react icons with available @trycompai/design-system equivalents, and run the app type check to verify the migration.

  • Migrating legacy UI components
  • Replacing lucide-react icons with Carbon icons
  • Checking specified files for design system compliance
trycompai/comp2.1KUpdated Oct 24, 2026

audit-hooks

FreeSummary

Review specified files for outdated hook and API patterns, then replace them with the prescribed SWR hooks, API clients, or server API calls. The guidance covers data fetching, mutations, cache updates, and response handling, followed by a typecheck command.

  • Auditing files for disallowed API and hook patterns
  • Replacing raw fetch calls with the API client
  • Migrating server actions and database mutations to API hooks
trycompai/comp2.1KUpdated Oct 24, 2026

audit-rbac

FreeSummary

Review NestJS API endpoints and frontend components for role-based access control and audit log compliance. The skill lists permission, guard, route, and UI gating rules, then directs the agent to fix violations and run type checks.

  • Auditing API routes for permission decorators
  • Checking UI actions against user permissions
  • Fixing access control inconsistencies
trycompai/comp2.1KUpdated Oct 24, 2026

audit-tests

FreeSummary

Audit unit tests for components that use permissions. Add missing tests and fix failures, checking that administrators can use mutation controls, auditors cannot, and read-only content remains visible to both.

  • Adding permission tests for a component
  • Checking admin and auditor behavior
  • Fixing failing permission-related tests
trycompai/comp2.1KUpdated Oct 24, 2026

Set up Better Auth for TypeScript applications, including server and client configuration, database adapters, sessions, email and social sign-in, and plugins. The guide also highlights environment variables, schema generation, and security settings to review.

  • Configuring Better Auth in a TypeScript app
  • Connecting an ORM or database adapter
  • Setting up sessions and cookie storage
trycompai/comp2.1KUpdated Oct 24, 2026

See all skills by trycompai

Report a problem with this skill