---
name: prompt-engineering
description: Expert guidance on crafting high-fidelity prompts using the CO-STAR framework
license: MIT
metadata:
  version: "1.0"
  framework: CO-STAR
---

# Skill: Prompt Engineering (CO-STAR)

**Description:** Expert guidance on crafting high-fidelity prompts using the CO-STAR framework. Use this skill when the user asks to "improve", "refine", or "optimize" a prompt, or when the `prompt-improver` tool is invoked.

## The CO-STAR Framework

To generate optimal results from an LLM, structure prompts using these six components:

1.  **C (Context):** Provide background information, user role, and scenario.
    - _Bad:_ "Write code for a login."
    - _Good:_ "I am a senior frontend engineer building a banking app. We need a secure login form using React and TypeScript."

2.  **O (Objective):** Clearly define the task and the desired outcome.
    - _Bad:_ "Fix this."
    - _Good:_ "Refactor the `AuthService` class to implement the Singleton pattern and handle token expiration."

3.  **S (Style):** Specify the writing style (e.g., professional, concise, academic, humorous).
    - _Bad:_ "Make it sound good."
    - _Good:_ "Use a formal, technical tone suitable for internal documentation."

4.  **T (Tone):** Set the emotional resonance (e.g., empathetic, authoritative, neutral).
    - _Bad:_ "Don't be rude."
    - _Good:_ "Maintain a helpful and encouraging tone, as this feedback is for a junior developer."

5.  **A (Audience):** Identify who will consume the output.
    - _Bad:_ "For people."
    - _Good:_ "Target audience is non-technical stakeholders who need to understand the project timeline."

6.  **R (Response):** Define the output format (e.g., JSON, Markdown table, Python script).
    - _Bad:_ "Give me the answer."
    - _Good:_ "Output the result as a Markdown table with columns for 'Feature', 'Status', and 'Owner'."

## Optimization Checklist

When refining a prompt, ensure it answers:

- [ ] **Who** is asking? (Context)
- [ ] **What** exactly do they want? (Objective)
- [ ] **How** should it look/sound? (Style/Tone)
- [ ] **Who** is it for? (Audience)
- [ ] **What format** is required? (Response)

## Common Pitfalls

- **Over-constraining:** Adding too many rules can confuse the model. Stick to the 6 CO-STAR points.
- **Vague Objectives:** "Write code" is bad. "Write a Python script to parse CSV" is good.
- **Missing Context:** The model doesn't know your project unless you tell it.
- **Ignoring Audience:** A technical explanation for a CEO is usually a failure.

## Example Refinement

**Input:**
"Help me write a blog post about AI."

**Refined (CO-STAR):**
"**Context:** I am a tech enthusiast writing for a general audience on Medium.
**Objective:** Write a 1000-word blog post explaining 'Agentic Workflows' in AI.
**Style:** Engaging, accessible, yet informative. Use analogies to explain complex concepts.
**Tone:** Optimistic and forward-looking.
**Audience:** Tech-savvy readers who are not AI experts.
**Response:** Markdown format with H2 headers and a 'Key Takeaways' section at the end."
