Agent Skills 与上下文工程(1/3)

Escape Syntax

Use \!`cmd` to output the literal text !`cmd` without execution:

###
Documenting the Syntax

To execute a command, use \!`command` syntax.
For example: \!`git status` shows the current git state.

Output:

###
Documenting the Syntax

To execute a command, use !`command` syntax.
For example: !`git status` shows the current git state.

Error Handling

Failed commands return inline error markers:

Scenario Output
Command fails [Error: Commandxyzexited with code 1: error message]
Command times out [Error: Commandxyztimed out after 10s]
Large output (>50KB) Output truncated with ... [output truncated]

Programmatic Rendering

When using skills programmatically, call render_content() to execute commands:

from openhands.sdk.context import Skill

skill = Skill.load("/path/to/skill/SKILL.md")

###
Render with command execution
rendered = skill.render_content(working_dir="/path/to/repo")
print(rendered)  # Commands replaced with output

The working_dir parameter sets the current directory for command execution, enabling workspace-relative commands like git status.

Migrating from Legacy to AgentSkills Format

If you have legacy inline skills consuming many tokens, convert them to AgentSkills format for progressive disclosure:

Before (Legacy Format)

###
Legacy: Full content in <REPO_CONTEXT> in the initial system prompt
Skill(
    name="api-guidelines",
    content="""
    # API Guidelines
    ... 2000 lines of detailed documentation ...
    """,
    trigger=None,  # Always-on context - affects token usage on each turn!
)

After (AgentSkills Format)

Create a directory api-guidelines/SKILL.md:

---
name: api-guidelines
description: Comprehensive API design guidelines for the project. Invoke when designing or reviewing API endpoints.
---

###
API Guidelines

... 2000 lines of detailed documentation ...

Then load it:

from openhands.sdk.skills import load_skills_from_dir

###
AgentSkills: Only description in prompt, agent reads full content on demand
_, _, skills = load_skills_from_dir("/path/to/skills")
agent_context = AgentContext(skills=list(skills.values()))
Benefits
Aspect Legacy trigger=None AgentSkills SKILL.md
Token usage Full content in system prompt; included in LLM context for each turn Description only (\~100 chars)
Model control None — always present Agent decides when to read
Scalability Limited by context window Many skills without token bloat

Next Steps


High-level architecture of the reusable prompt system

The Skill system provides a mechanism for injecting reusable, specialized knowledge into agent context. Skills use trigger-based activation to determine when they should be included in the agent's prompt.

Source: openhands/sdk/context/skills/

Core Responsibilities

The Skill system has five primary responsibilities:

  1. Context Injection - Add specialized prompts to agent context based on triggers
  2. Trigger Evaluation - Determine when skills should activate (always, keyword, task, path)
  3. Dynamic Content Rendering - Execute inline shell commands for dynamic context injection
  4. MCP Integration - Load MCP tools associated with repository skills
  5. Third-Party Support - Parse .cursorrules, agents.md, and other skill formats

Architecture

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 25, "rankSpacing": 35}} }%%
flowchart TB
    subgraph Types["Skill Types"]
        Repo["Repository Skill<br><i>trigger: None</i>"]
        Knowledge["Knowledge Skill<br><i>trigger: KeywordTrigger</i>"]
        Task["Task Skill<br><i>trigger: TaskTrigger</i>"]
        Rule["Path Rule<br><i>trigger: PathTrigger</i>"]
    end

    subgraph Triggers["Trigger Evaluation"]
        Always["Always Active<br><i>Repository guidelines</i>"]
        Keyword["Keyword Match<br><i>String matching on user messages</i>"]
        TaskMatch["Keyword Match + Inputs<br><i>Same as KeywordTrigger + user inputs</i>"]
        PathMatch["File-Touch Match<br><i>Glob match on touched file path</i>"]
    end

    subgraph Content["Skill Content"]
        Markdown["Markdown with Frontmatter"]
        Dynamic["Dynamic Commands<br><i>!`command` execution</i>"]
        MCPTools["MCP Tools Config<br><i>Repo skills only</i>"]
        Inputs["Input Metadata<br><i>Task skills only</i>"]
    end

    subgraph Integration["Agent Integration"]
        Context["Agent Context"]
        Prompt["System Prompt"]
        ToolResult["Tool Result<br><i>Rules injected on file-touch</i>"]
    end

    Repo --> Always
    Knowledge --> Keyword
    Task --> TaskMatch
    Rule --> PathMatch

    Always --> Markdown
    Keyword --> Markdown
    TaskMatch --> Markdown
    PathMatch --> ToolResult

    Markdown -.->|Optional| Dynamic
    Repo -.->|Optional| MCPTools
    Task -.->|Requires| Inputs

    Markdown --> Context
    Dynamic --> Context
    MCPTools --> Context
    Context --> Prompt

    classDef primary fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    classDef secondary fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px
    classDef tertiary fill:#fff4df,stroke:#b7791f,stroke-width:2px
    classDef dynamic fill:#e9f9ef,stroke:#2f855a,stroke-width:2px

    class Repo,Knowledge,Task,Rule primary
    class Always,Keyword,TaskMatch,PathMatch secondary
    class Context,ToolResult tertiary
    class Dynamic dynamic
Key Components
Component Purpose Design
Skill Core skill model Pydantic model with name, content, trigger
KeywordTrigger Keyword-based activation String matching on user messages
TaskTrigger Task-based activation Special type of KeywordTrigger for skills with user inputs
PathTrigger Path-based activation ("rules") Glob match on a touched file path; injected into the tool result, not model-invocable
InputMetadata Task input parameters Defines user inputs for task skills
render_content_with_commands Dynamic content Executes inline !command`` patterns
Skill Loader File parsing Reads markdown with frontmatter, validates schema

Skill Types

Repository Skills

Always-active, repository-specific guidelines.

Recommended: put these permanent instructions in AGENTS.md (and optionally GEMINI.md / CLAUDE.md) at the repo root.

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30, "rankSpacing": 40}} }%%
flowchart LR
    File["AGENTS.md"]
    Parse["Parse Frontmatter"]
    Skill["Skill(trigger=None)"]
    Context["Always in Context"]

    File --> Parse
    Parse --> Skill
    Skill --> Context

    style Skill fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style Context fill:#fff4df,stroke:#b7791f,stroke-width:2px

Characteristics:

  • Trigger: None (always active)
  • Purpose: Project conventions, coding standards, architecture rules
  • MCP Tools: Can include MCP tool configuration
  • Location: AGENTS.md (recommended) and/or .agents/skills/*.md (supported)

Example Files (permanent context):

  • AGENTS.md - General agent instructions
  • GEMINI.md - Gemini-specific instructions
  • CLAUDE.md - Claude-specific instructions

Other supported formats:

  • .cursorrules - Cursor IDE guidelines
  • agents.md / agent.md - General agent instructions
Knowledge Skills

Keyword-triggered skills for specialized domains:

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30, "rankSpacing": 40}} }%%
flowchart TB
    User["User Message"]
    Check["Check Keywords"]
    Match{"Match?"}
    Activate["Activate Skill"]
    Skip["Skip Skill"]
    Context["Add to Context"]

    User --> Check
    Check --> Match
    Match -->|Yes| Activate
    Match -->|No| Skip
    Activate --> Context

    style Check fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style Activate fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px

Characteristics:

  • Trigger: KeywordTrigger with regex patterns
  • Purpose: Domain-specific knowledge (e.g., "kubernetes", "machine learning")
  • Activation: Keywords detected in user messages
  • Location: System or user-defined knowledge base

Trigger Example:

---
name: kubernetes
trigger:
  type: keyword
  keywords: ["kubernetes", "k8s", "kubectl"]
---
Task Skills

Keyword-triggered skills with structured inputs for guided workflows:

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30, "rankSpacing": 40}} }%%
flowchart TB
    User["User Message"]
    Match{"Keyword<br>Match?"}
    Inputs["Collect User Inputs"]
    Template["Apply Template"]
    Context["Add to Context"]
    Skip["Skip Skill"]

    User --> Match
    Match -->|Yes| Inputs
    Match -->|No| Skip
    Inputs --> Template
    Template --> Context

    style Match fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style Template fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px

Characteristics:

  • Trigger: TaskTrigger (a special type of KeywordTrigger for skills with user inputs)
  • Activation: Keywords/triggers detected in user messages (same matching logic as KeywordTrigger)
  • Purpose: Guided workflows (e.g., bug fixing, feature implementation)
  • Inputs: User-provided parameters (e.g., bug description, acceptance criteria)
  • Location: System-defined or custom task templates

Trigger Example:

---
name: bug_fix
triggers: ["/bug_fix", "fix bug", "bug report"]
inputs:
  - name: bug_description
    description: "Describe the bug"
    required: true
---

Note: TaskTrigger uses the same keyword matching mechanism as KeywordTrigger. The distinction is semantic - TaskTrigger is used for skills that require structured user inputs, while KeywordTrigger is for knowledge-based skills.

Path Skills (Rules)

Skills that are injected deterministically when the agent touches a matching file, modeled on Claude Code "rules":

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30, "rankSpacing": 40}} }%%
flowchart TB
    Touch["Agent Reads/Edits/Creates File"]
    Match{"Path Matches<br>Glob?"}
    Inject["Inject into Tool Result"]
    Skip["Skip Rule"]
    Dedup["Dedup: once per conversation"]

    Touch --> Match
    Match -->|Yes| Dedup
    Match -->|No| Skip
    Dedup --> Inject

    style Match fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style Inject fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px

Characteristics:

  • Trigger: PathTrigger with gitignore-style paths globs (matched against the workspace-relative POSIX path)
  • Activation: The agent reads, edits, or creates a file whose path matches a glob (fires on create too)
  • Injection point: Folded into the ObservationEvent tool result (extended_content) as an <EXTRA_INFO> block — not the user message
  • Baseline cost: Zero — excluded from <available_skills> and <REPO_CONTEXT>; disable_model_invocation is forced, so rules are never model-invocable
  • Dedup: Each rule is injected only once per conversation (tracked via ConversationState.activated_path_rules)
  • Location: Any skills directory (e.g. .agents/skills/*.md) — a rule is just a skill with paths: frontmatter

Trigger Example:

---
paths:
  - "src/api/**/*.ts"
  - "**/*.route.ts"
---

Note: A skill is either path-triggered or model-invocable, not both — if a file declares both paths: and triggers:, paths: wins. Path-rule injection applies to local conversations; ACP-backed conversations do not inject rules because the ACP server owns tool execution.

Trigger Evaluation

Skills are evaluated at different points in the agent lifecycle:

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30, "rankSpacing": 40}} }%%
flowchart TB
    Start["Agent Step Start"]

    Repo["Check Repository Skills<br><i>trigger: None</i>"]
    AddRepo["Always Add to Context"]

    Message["Check User Message"]
    Keyword["Match Keyword Triggers"]
    AddKeyword["Add Matched Skills"]

    TaskType["Check Task Type"]
    TaskMatch["Match Task Triggers"]
    AddTask["Add Task Skill"]

    Build["Build Agent Context"]

    Start --> Repo
    Repo --> AddRepo

    Start --> Message
    Message --> Keyword
    Keyword --> AddKeyword

    Start --> TaskType
    TaskType --> TaskMatch
    TaskMatch --> AddTask

    AddRepo --> Build
    AddKeyword --> Build
    AddTask --> Build

    style Repo fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style Keyword fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px
    style TaskMatch fill:#fff4df,stroke:#b7791f,stroke-width:2px

Evaluation Rules:

Trigger Type Evaluation Point Activation Condition
None Every step Always active
KeywordTrigger On user message Keyword/string match in message
TaskTrigger On user message Keyword/string match in message (same as KeywordTrigger)
PathTrigger On tool observation Glob match on the touched file's path (read/edit/create)

Note: Both KeywordTrigger and TaskTrigger use identical string matching logic. TaskTrigger is simply a semantic variant used for skills that include user input parameters.

MCP Tool Integration

Repository skills can include MCP tool configurations:

%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30}} }%%
flowchart LR
    Skill["Repository Skill"]
    MCPConfig["mcp_tools Config"]
    Client["MCP Client"]
    Tools["Tool Registry"]

    Skill -->|Contains| MCPConfig
    MCPConfig -->|Spawns| Client
    Client -->|Registers| Tools

    style Skill fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style MCPConfig fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px
    style Tools fill:#fff4df,stroke:#b7791f,stroke-width:2px

MCP Configuration Format:

Skills can embed MCP server configuration following the FastMCP format:

---
name: repo_skill
mcp_tools:
  mcpServers:
    filesystem:
      command: "npx"
      args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
---

Workflow:

  1. Load Skill: Parse markdown file with frontmatter
  2. Extract MCP Config: Read mcp_tools field
  3. Spawn MCP Servers: Create MCP clients for each server
  4. Register Tools: Add MCP tools to agent's tool registry
  5. Inject Context: Add skill content to agent prompt

Dynamic Content Rendering

Skills support inline command execution for injecting dynamic context at render time:

  1. Parse content for !`cmd` patterns outside code blocks
  2. Execute each command via subprocess
  3. Replace pattern with stdout (or error marker)
  4. Return rendered content

Syntax:

  • !`command` - Executes command and replaces with stdout
  • \!`command` - Escapes to literal !`command` text
  • Fenced (```) and inline (`) code blocks are never executed

Safety:

  • Unclosed fenced blocks (odd ``` count) extend to EOF, protecting trailing content
  • Failed commands return [Error: ...] markers
  • Output truncated at 50KB per command

See Dynamic Command Execution for usage details.

Skill File Format

Skills are defined in markdown files with YAML frontmatter:

---
name: skill_name
trigger:
  type: keyword
  keywords: ["pattern1", "pattern2"]
---

# Skill Content

This is the instruction text that will be added to the agent's context.
Dynamic values: !`git branch --show-current`

Frontmatter Fields:

Field Required Description
name Yes Unique skill identifier
trigger Yes* Activation trigger (null for always active)
paths No Glob patterns that make the skill a path-triggered rule (PathTrigger); takes precedence over triggers
mcp_tools No MCP server configuration (repo skills only)
inputs No User input metadata (task skills only)

*Repository skills use trigger: null (or omit trigger field)

Component Relationships

How Skills Integrate
%%{init: {"theme": "default", "flowchart": {"nodeSpacing": 30}} }%%
flowchart LR
    Skills["Skill System"]
    Context["Agent Context"]
    Agent["Agent"]
    MCP["MCP Client"]

    Skills -->|Injects content| Context
    Skills -.->|Spawns tools| MCP
    Context -->|System prompt| Agent
    MCP -->|Tool| Agent

    style Skills fill:#f3e8ff,stroke:#7c3aed,stroke-width:2px
    style Context fill:#e8f3ff,stroke:#2b6cb0,stroke-width:2px
    style Agent fill:#fff4df,stroke:#b7791f,stroke-width:2px

Relationship Characteristics:

  • Skills → Agent Context: Active skills contribute their content to system prompt
  • Skills → MCP: Repository skills can spawn MCP servers and register tools
  • Context → Agent: Combined skill content becomes part of agent's instructions
  • Skills Lifecycle: Loaded at conversation start, evaluated each step

See Also


Learn how to create reusable skills instead of repeating prompts, with best practices for structure, triggers, and content organization.

Instead of repeating the same prompts or instructions in every conversation, create a skill that OpenHands can load automatically when needed. Skills transform one-time prompts into reusable, maintainable knowledge that improves over time.

Why Create Skills?

Before (repeating yourself):

Please analyze this code using our company's Python style guide:
- Use black for formatting
- Max line length 88
- Use type hints for all functions
- Follow PEP 8 naming conventions
...

After (using a skill):

Review this Python code

The skill triggers automatically and applies all your style guidelines consistently.

When to Create a Skill

Create a skill when you find yourself:

  • Repeating the same instructions across multiple conversations
  • Working with domain-specific knowledge (company policies, API schemas, workflows)
  • Using the same multi-step procedures repeatedly
  • Needing consistent behavior for specific tools or frameworks
  • Sharing best practices across a team

Quick Start

Automated Approach: Let OpenHands Help

To create a skill with guided assistance, ask OpenHands to help you:

Create a skill for [your use case]

or simply:

Write a new skill

The skill-creator skill (from the OpenHands public skills library) will guide you through an interactive process:

  • Asks questions about your use cases and requirements
  • Suggests appropriate skill structure (references, scripts, assets)
  • Helps you write effective trigger keywords and descriptions
  • Ensures you follow best practices automatically
  • Creates the complete skill structure for you

This is the recommended approach, especially when you're starting out.

Manual Approach

If you prefer to create the skill structure manually:

  1. Create the skill directory:
mkdir -p .agents/skills/my-skill
  1. Create the SKILL.md file:
touch .agents/skills/my-skill/SKILL.md
  1. Add content (see structure and guidelines below)

  2. Test it by using a trigger keyword in your prompt

Determining Scope

Before writing your skill, define its scope clearly:

Ask These Questions
  1. What specific task does this skill handle?
  2. ❌ Too broad: "Help with coding"
  3. ✅ Focused: "Lint Python code using ruff with our company rules"

  4. What knowledge is required?

  5. Code style guidelines
  6. API documentation
  7. Domain-specific schemas
  8. Multi-step procedures

  9. What resources are needed?

  10. Scripts for deterministic tasks
  11. Reference documents for detailed information
  12. Asset files for templates or boilerplate

  13. Who will use this skill?

  14. Just you (keep it simple)
  15. Your team (add more documentation)
  16. Public sharing (comprehensive examples)
Scope Examples

Good scope (focused):

  • "Configure pre-commit hooks for Python projects"
  • "Generate financial reports using our SQL schema"
  • "Deploy to our Kubernetes staging environment"

Poor scope (too broad):

  • "Help with Python"
  • "Work with databases"
  • "Deploy applications"

Choosing Name and Triggers

The skill name and trigger keywords determine when OpenHands loads your skill.

Naming Your Skill

Choose a clear, descriptive name:

  • Use lowercase with hyphens: python-linting, k8s-deploy, api-docs
  • Be specific: ruff-linter not just linter
  • Match common terms: Use vocabulary your users know
Defining Triggers

Triggers are keywords that automatically activate your skill. Choose words users naturally say when they need this skill.

<AccordionGroup>

List specific words or phrases that should activate the skill:
---
name: python-linting
description: This skill should be used when the user asks to "lint Python code", "check Python style", "run ruff", or mentions Python code quality.
triggers:
- lint
- linting
- ruff
- code quality
---
**Best practices:**

* Include 2-5 trigger keywords
* Use terms users actually say
* Include tool names (e.g., "ruff", "pytest")
* Include action words (e.g., "lint", "test", "deploy")



The skill description is crucial for trigger matching. Write it in third person and include specific phrases:
description: This skill should be used when the user asks to "deploy to Kubernetes", "apply K8s manifests", "check pod status", or mentions kubectl commands. Provides comprehensive Kubernetes deployment workflows.
**Key elements:**

* Start with "This skill should be used when..."
* Quote specific user phrases: "deploy to Kubernetes"
* List concrete scenarios
* Mention related tools or frameworks



Instead of keywords, scope a skill to files with a `paths:` glob. The skill
becomes a [path-triggered rule](https://docs.openhands.dev/overview/skills/path) that OpenHands injects
automatically whenever the agent reads, edits, or creates a matching file — no
keyword or model decision needed:
---
name: api-validation
paths:
  - "src/api/**/*.ts"
  - "**/*.route.ts"
---
**When to use:**

* Conventions tied to specific files (e.g. "validate request inputs with zod" for API routes)
* Guidance you want applied deterministically, without relying on trigger words
* `paths:` takes precedence over `triggers:` if a file declares both

</AccordionGroup>

Examples of Good Triggers
# API integration skill
triggers:
- stripe
- payment
- checkout
# Database skill
triggers:
- bigquery
- sql query
- data warehouse
# Deployment skill
triggers:
- deploy
- kubernetes
- k8s
- kubectl

Defining the Skill Body

The skill body contains the instructions OpenHands will follow. Write in imperative form (command form) rather than second person.

Basic Structure
---
name: skill-name
description: This skill should be used when...
triggers:
- keyword1
- keyword2
---

# Skill Title

Brief overview of what this skill does.

## Core Instructions

Main procedures and guidelines.

## Common Patterns

Typical use cases and solutions.

## Additional Resources

(Optional) References to bundled files.
Writing Style

Use imperative/infinitive form: ✅ "Check the configuration file" ✅ "Validate input before processing" ✅ "Run tests after deployment"

Avoid second person: ❌ "You should check the configuration" ❌ "You need to validate input" ❌ "You must run tests"

Keep It Focused

SKILL.md content:

  • Core concepts and workflows (1,500-2,000 words ideal)
  • Essential procedures
  • Quick reference information
  • Pointers to additional resources

What NOT to include:

  • Exhaustive API documentation (use references/ instead)
  • Detailed edge cases (use references/ instead)
  • Long examples (use references/ instead)

Best Practices and Tips

Use Numbered Step Workflows

For multi-step procedures, use numbered lists:

## Deployment Workflow

1. **Validate the configuration**:
   ```bash
   kubectl apply --dry-run=client -f deployment.yaml
  1. Apply to staging: ```bash kubectl apply -f deployment.yaml -n staging

3. **Verify pod status**:
```bash
kubectl get pods -n staging --watch
  1. Check logs:
kubectl logs -f deployment/app-name -n staging

**Benefits:**
- Clear sequence for complex workflows
- Easy to follow and verify
- Reduces errors from skipped steps

##### Add Large Files as References

Keep SKILL.md lean by moving detailed content to `references/`:

my-skill/ ├── SKILL.md # Core instructions (\< 3,000 words) └── references/ ├── api-docs.md # Detailed API reference ├── examples.md # Comprehensive examples └── troubleshooting.md # Edge cases and fixes


**In SKILL.md, reference these files:**

```markdown
## Additional Resources

For detailed information, see:
- **`references/api-docs.md`** - Complete API documentation
- **`references/examples.md`** - Working code examples
- **`references/troubleshooting.md`** - Common issues and solutions

Benefits:

  • Keeps context window smaller when skill loads
  • OpenHands reads references only when needed
  • Easier to maintain and update specific sections
Create Scripts for Predictable Steps

For tasks that are repeatedly rewritten or need deterministic behavior, create executable scripts:

my-skill/
├── SKILL.md
└── scripts/
    ├── validate_config.py
    ├── deploy.sh
    └── rollback.sh

When to use scripts:

  • Same code being rewritten repeatedly
  • Deterministic reliability required
  • Complex parsing or validation
  • Multi-step automation

Reference scripts in SKILL.md:

## Validation

Run the validation script:

\`\`\`bash
python3 scripts/validate_config.py config.yaml
\`\`\`

This checks:
- YAML syntax
- Required fields
- Value constraints

Benefits:

  • Token efficient (scripts can run without being read)
  • Deterministic behavior
  • Reusable across projects
  • Can be versioned and tested
Include Quick Reference Tables

Use tables for configuration options, command flags, or status codes:

## Configuration Options

| Option | Default | Description |
|--------|---------|-------------|
| `timeout` | 30s | Maximum wait time |
| `retries` | 3 | Number of retry attempts |
| `env` | production | Target environment |
Provide Concrete Examples

Show real examples, not abstract descriptions:

## Example Usage

Deploy the web application:

\`\`\`bash
# Build the image
docker build -t myapp:v1.0 .

# Push to registry
docker push registry.example.com/myapp:v1.0

# Update Kubernetes deployment
kubectl set image deployment/web web=registry.example.com/myapp:v1.0
\`\`\`
Use Progressive Disclosure

Structure information from simple to complex:

  1. SKILL.md: Essential workflows and core concepts
  2. references/: Detailed patterns, advanced techniques, edge cases
  3. scripts/: Automation for predictable tasks
  4. assets/: Templates and boilerplate files

Complete Example

Here's a complete skill for Python code review:

python-review/
├── SKILL.md
├── references/
│   ├── style-guide.md
│   └── common-issues.md
└── scripts/
    └── run-checks.sh

SKILL.md:

---
name: python-review
description: This skill should be used when the user asks to "review Python code", "check Python style", "lint Python", or requests code quality analysis. Provides comprehensive Python code review workflows.
triggers:
- python review
- code review
- lint python
- black
- ruff
---

# Python Code Review

Review Python code using company standards and best practices.

## Review Workflow

1. **Run automated checks**:
   \`\`\`bash
   scripts/run-checks.sh
   \`\`\`

2. **Review linter output** for:
   - Style violations (Black, Ruff)
   - Type errors (mypy)
   - Security issues (bandit)

3. **Check code structure**:
   - Function length (< 50 lines)
   - Complexity (< 10 cyclomatic)
   - Naming conventions

4. **Verify tests**:
   \`\`\`bash
   pytest tests/ --cov=src --cov-report=term
   \`\`\`

## Style Guidelines

- **Formatting**: Black with 88-character line limit
- **Linting**: Ruff with company config
- **Types**: Full type hints for public APIs
- **Docstrings**: Google style for all public functions

## Additional Resources

- **`references/style-guide.md`** - Complete style guide
- **`references/common-issues.md`** - Common mistakes and fixes
- **`scripts/run-checks.sh`** - Automated quality checks

Testing Your Skill

After creating your skill:

  1. Verify structure:
ls .agents/skills/your-skill/SKILL.md
  1. Check frontmatter: Ensure YAML is valid with name, description, and triggers

  2. Test trigger keywords: Use a trigger word in a prompt:

Help me lint this Python code
  1. Verify loading: OpenHands should indicate the skill was loaded

  2. Iterate: Improve based on actual usage

For production deployments, see Monitoring and Improving Skills to track performance using logging, evaluation metrics, dashboarding, and automated feedback aggregation.

Common Mistakes to Avoid

Mistake 1: Vague triggers ❌ description: Helps with Python ✅ description: This skill should be used when the user asks to "lint Python code", "run black", or mentions Python code quality

Mistake 2: Everything in SKILL.md ❌ Single 10,000-word SKILL.md ✅ Focused SKILL.md (2,000 words) + references/ for details

Mistake 3: Using "you" in instructions ❌ "You should validate the config" ✅ "Validate the config"

Mistake 4: Missing examples ❌ Abstract descriptions only ✅ Concrete examples with actual commands

Next Steps

Further Reading

For advanced skill creation techniques and SDK integration: