Agent Skills 与上下文工程(3/3)
Give OpenHands reusable instructions, domain knowledge, workflows, and supporting resources.
Skills give OpenHands reusable instructions for specialized tasks. A skill can capture domain knowledge, define a repeatable workflow, and include supporting scripts, references, or templates.
Skills guide the agent's behavior; they do not grant permissions or install dependencies by themselves. The agent can only use the files, tools, secrets, and network access available in its environment.
OpenHands supports the Agent Skills specification and adds optional features such as keyword triggers and path-triggered rules. Other Agent Skills clients may ignore these OpenHands extensions.
Choose the Right Mechanism
| Need | Use | Recommended Location | Loading Behavior |
|---|---|---|---|
| Instructions for every task in a repository | AGENTS.md |
Repository root | Full content is included in the initial system prompt |
| Reusable expertise or a workflow for a specific task | Agent Skills SKILL.md |
.agents/skills/<skill-name>/SKILL.md |
Name and description are advertised first; the agent invokes the full skill when relevant |
| Automatic activation for specific words or commands | SKILL.md with triggers |
.agents/skills/<skill-name>/SKILL.md |
The skill remains available for model invocation and its content is also injected when a trigger matches |
| Deterministic guidance for specific files | A skill with paths |
.agents/skills/<skill-name>/SKILL.md or .agents/skills/<rule-name>.md |
Content is injected when the agent first touches a matching file |
Use AGENTS.md for short, repository-wide conventions. Use SKILL.md for focused knowledge that is needed only for some tasks. A legacy .md skill without a trigger is always loaded in full; prefer AGENTS.md for that use case so its purpose is clear.
OpenHands also recognizes CLAUDE.md and GEMINI.md as model-specific repository context.
How Progressive Disclosure Works
Agent Skills use three levels of context:
- Discovery: OpenHands loads each skill's
nameanddescriptioninto the available-skills catalog. - Invocation: When a task matches the description, the agent invokes the skill by name and receives the full
SKILL.mdinstructions. - Resources: The agent reads referenced files from
scripts/,references/, orassets/only when needed.
This keeps the initial prompt smaller than loading every skill in full. Write the description to explain both what the skill does and when it applies; the agent uses that metadata to decide whether to invoke it.
OpenHands supports two deterministic activation paths:
triggersinjects the skill when a keyword or command appears in a user message. The skill is still available for model invocation.pathsturns the file into a path-triggered rule. The rule is not advertised to the model and is injected once per conversation when a matching file is read, edited, or created. If a file declares bothpathsandtriggers,pathstakes precedence.
Always-on content occupies the conversation context from the beginning. Keep AGENTS.md concise and move lengthy or specialized instructions into on-demand skills and references.
Official Skill Registry
The official global skill registry is maintained at github.com/OpenHands/extensions. This repository contains community-shared skills that can be used by all OpenHands agents. You can browse available skills, contribute your own, and learn from examples created by the community.
Five-Minute Setup
Add concise repository guidance and one on-demand skill:
my-repository/
├── AGENTS.md
└── .agents/
└── skills/
└── release-checklist/
└── SKILL.md
# Repository Guidance
Run the test suite before committing. Keep changes focused and follow the existing project conventions.
---
name: release-checklist
description: Prepare and verify a release checklist. Use when creating release notes or publishing a release.
---
Check the version, changelog, validation commands, and release notes before publishing.
For a portable Agent Skills package, name and description are required. The name must match the parent directory and use lowercase letters, numbers, and hyphens. See Creating Skills for the complete format and authoring guidance.
Start a new conversation after changing skill files so OpenHands rebuilds the available-skills catalog.
Skill Locations and Precedence
OpenHands can combine skills from several scopes:
| Scope | Recommended Location | Applies To |
|---|---|---|
| Repository context | <repository>/AGENTS.md |
Conversations in that repository |
| Project skills | <project>/.agents/skills/ |
Conversations using that project workspace |
| User skills | ~/.agents/skills/ |
Conversations for that user |
| Public skills | OpenHands extensions registry | Conversations configured to load the public registry |
Both the legacy .openhands/skills/ and .openhands/microagents/ directories remain supported, but use .agents/skills/ for new skills. This location follows the Agent Skills standard and makes skills portable across compatible agent tools.
Name conflicts are resolved by precedence rather than by merging skill bodies. For automatically loaded sources, project skills override user skills, and user skills override public skills. Within a project or user scope, .agents/skills/ takes precedence over the legacy directories.
In the SDK, explicitly supplied skills override automatically loaded user and public skills. Project skills are resolved from the conversation workspace and override a same-named skill from another source. See the SDK Skills Guide for loader configuration.
OpenHands-Specific Skill Types
- Repository Context provides always-on project instructions.
- Keyword-Triggered Skills activate when a user message contains configured terms.
- Path-Triggered Rules apply deterministic instructions to matching files.
- Organization and User Skills share guidance across repositories.
- Global Skills are reusable skills published through the OpenHands extensions registry.
Using Skills Across OpenHands
| Surface | How Skills Are Loaded |
|---|---|
| Agent Canvas | Manage installed skills under Customize > Skills; configuration is scoped to the active backend |
| SDK and agent server | Pass Skill objects directly or enable the user, project, and public file-based loaders in AgentContext |
| OpenHands Cloud | Select or import skills for a conversation, including skills stored in Git repositories |
In Agent Canvas, disabling a bundled or custom skill prevents it from being included in the agent context for new OpenHands and ACP conversations. Enabled skills remain available to new conversations.
The skill catalog defaults to an explicit allow-list of recommended skills rather than enabling every available skill. The Customize > Skills page shows the full catalog with a Recommended badge and facet; only the recommended skills are enabled by default. You can enable any additional skill individually. An existing deny-list still takes precedence over the default allow-list.
See Customize and Settings for Agent Canvas and Plugin Launcher for loading a Git-hosted skill into an OpenHands Cloud conversation.
Review a skill and its bundled resources before installing it. A skill can instruct the agent to run scripts, read files, use secrets, or call connected tools. Only install skills from sources you trust.
Next Steps
- Add an Existing Skill
- Create a Skill
- Browse the OpenHands Skills Registry
- Bundle Skills in a Plugin
- Monitor and Improve Skills
Learn More
- For SDK integration: See SDK Skills Guide
- For architecture details: See Skills Architecture
- For specific skill types: See Repository Skills, Keyword Skills, Path-Triggered Rules, Organization Skills, and Global Skills
Model Context Protocol (MCP) enables dynamic tool integration from external servers. Agents can discover and use MCP-provided tools automatically.
MCP (Model Context Protocol) is a protocol for exposing tools and resources to AI agents. Read more about MCP here.
Basic MCP Usage
The ready-to-run basic MCP usage example is available here!
### MCP Configuration
Configure MCP servers using a dictionary with server names and connection details following [this configuration format](https://gofastmcp.com/clients/client#configuration-format)
mcp_config = {
"mcpServers": {
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"]
},
"repomix": {
"command": "npx",
"args": ["-y", "repomix@1.4.2", "--mcp"]
},
}
}
### Tool Filtering
Use `filter_tools_regex` to control which MCP tools are available to the agent
agent = Agent(
llm=llm,
tools=tools,
mcp_config=mcp_config,
filter_tools_regex="^(?!repomix)(.*)|^repomix.*pack_codebase.*$",
)
MCP with OAuth
The ready-to-run MCP with OAuth example is available here!
For MCP servers requiring OAuth authentication:
- Configure OAuth-enabled MCP servers by specifying the URL and auth type
- The SDK automatically handles the OAuth flow when first connecting
- When the agent first attempts to use an OAuth-protected MCP server's tools, the SDK initiates the OAuth flow via FastMCP
- User will be prompted to authenticate via browser
- Access tokens are securely stored in
~/.fastmcp/oauth-mcp-client-cache/and automatically refreshed by FastMCP as needed
mcp_config = {
"mcpServers": {
"Notion": {
"url": "https://mcp.notion.com/mcp",
"auth": "oauth"
}
}
}
OAuth MCP servers require user interaction for the initial browser-based authentication. This means they are not suitable for fully automated/headless workflows. If you need headless access, check if the MCP provider offers API key authentication as an alternative.
Ready-to-Run Basic MCP Usage Example
This example is available on GitHub: examples/01_standalone_sdk/07_mcp_integration.py
Here's an example integrating MCP servers with an agent:
import os
from pydantic import SecretStr
from openhands.sdk import (
LLM,
Agent,
Conversation,
Event,
LLMConvertibleEvent,
get_logger,
)
from openhands.sdk.security.llm_analyzer import LLMSecurityAnalyzer
from openhands.sdk.tool import Tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
logger = get_logger(__name__)
# Configure LLM
api_key = os.getenv("LLM_API_KEY")
assert api_key is not None, "LLM_API_KEY environment variable is not set."
model = os.getenv("LLM_MODEL", "anthropic/claude-sonnet-4-5-20250929")
base_url = os.getenv("LLM_BASE_URL")
llm = LLM(
usage_id="agent",
model=model,
base_url=base_url,
api_key=SecretStr(api_key),
)
cwd = os.getcwd()
tools = [
Tool(name=TerminalTool.name),
Tool(name=FileEditorTool.name),
]
# Add MCP Tools
mcp_config = {
"mcpServers": {
"fetch": {"command": "uvx", "args": ["mcp-server-fetch"]},
"repomix": {"command": "npx", "args": ["-y", "repomix@1.4.2", "--mcp"]},
}
}
# Agent
agent = Agent(
llm=llm,
tools=tools,
mcp_config=mcp_config,
# This regex filters out all repomix tools except pack_codebase
filter_tools_regex="^(?!repomix)(.*)|^repomix.*pack_codebase.*$",
)
llm_messages = [] # collect raw LLM messages
def conversation_callback(event: Event):
if isinstance(event, LLMConvertibleEvent):
llm_messages.append(event.to_llm_message())
# Conversation
conversation = Conversation(
agent=agent,
callbacks=[conversation_callback],
workspace=cwd,
)
conversation.set_security_analyzer(LLMSecurityAnalyzer())
logger.info("Starting conversation with MCP integration...")
conversation.send_message(
"Read https://github.com/OpenHands/OpenHands and write 3 facts "
"about the project into FACTS.txt."
)
conversation.run()
conversation.send_message("Great! Now delete that file.")
conversation.run()
print("=" * 100)
print("Conversation finished. Got the following LLM messages:")
for i, message in enumerate(llm_messages):
print(f"Message {i}: {str(message)[:200]}")
# Report cost
cost = llm.metrics.accumulated_cost
print(f"EXAMPLE_COST: {cost}")
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.
Ready-to-Run MCP with OAuth Example
This example is available on GitHub: examples/01_standalone_sdk/08_mcp_with_oauth.py
import os
from pydantic import SecretStr
from openhands.sdk import (
LLM,
Agent,
Conversation,
Event,
LLMConvertibleEvent,
get_logger,
)
from openhands.sdk.tool import Tool
from openhands.tools.file_editor import FileEditorTool
from openhands.tools.terminal import TerminalTool
logger = get_logger(__name__)
# Configure LLM
api_key = os.getenv("LLM_API_KEY")
assert api_key is not None, "LLM_API_KEY environment variable is not set."
model = os.getenv("LLM_MODEL", "anthropic/claude-sonnet-4-5-20250929")
base_url = os.getenv("LLM_BASE_URL")
llm = LLM(
usage_id="agent",
model=model,
base_url=base_url,
api_key=SecretStr(api_key),
)
cwd = os.getcwd()
tools = [
Tool(
name=TerminalTool.name,
),
Tool(name=FileEditorTool.name),
]
mcp_config = {
"mcpServers": {"Notion": {"url": "https://mcp.notion.com/mcp", "auth": "oauth"}}
}
agent = Agent(llm=llm, tools=tools, mcp_config=mcp_config)
llm_messages = [] # collect raw LLM messages
def conversation_callback(event: Event):
if isinstance(event, LLMConvertibleEvent):
llm_messages.append(event.to_llm_message())
# Conversation
conversation = Conversation(
agent=agent,
callbacks=[conversation_callback],
)
logger.info("Starting conversation with MCP integration...")
conversation.send_message("Can you search about OpenHands V1 in my notion workspace?")
conversation.run()
print("=" * 100)
print("Conversation finished. Got the following LLM messages:")
for i, message in enumerate(llm_messages):
print(f"Message {i}: {str(message)[:200]}")
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o).
The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.
Next Steps
- Custom Tools - Creating native SDK tools
- Security Analyzer - Securing tool usage
- MCP Package Source Code - MCP integration implementation
Learn how to add existing skills to your OpenHands workspace from the official registry or custom repositories.
OpenHands makes it easy to extend your agent's capabilities by adding pre-built skills from the community or custom repositories. Skills can be added globally (available in all conversations) or to specific projects.
Using the Add-Skill Action
The quickest way to add a skill is using the /add-skill command in your conversation with OpenHands. This command fetches skills from GitHub repositories and installs them in your workspace.
Basic Usage
Provide a GitHub URL pointing to a skill:
/add-skill https://github.com/OpenHands/extensions/tree/main/skills/codereview
OpenHands will:
- Parse the URL to identify the repository and skill path
- Fetch the skill files from GitHub
- Install the skill in
.agents/skills/directory - Verify the installation
- Make the skill immediately available
Supported URL Formats
The /add-skill command accepts various GitHub URL formats:
- Full GitHub tree URL:
https://github.com/OpenHands/extensions/tree/main/skills/codereview - Repository path:
https://github.com/OpenHands/extensions/skills/codereview - Short form:
github.com/OpenHands/extensions/skills/codereview - Shorthand:
OpenHands/extensions/skills/codereview
Examples
Add the code review skill:
/add-skill https://github.com/OpenHands/extensions/tree/main/skills/codereview-roasted
Add the Kubernetes skill:
/add-skill OpenHands/extensions/skills/kubernetes
Add a skill from a custom repository:
/add-skill https://github.com/your-org/your-repo/tree/main/custom-skills/analytics
Skill Storage Locations
Skills are stored in different locations depending on the platform and scope:
The CLI supports two skill locations:
**User-level skills** (global, available in all conversations):
~/.openhands/skills/
**Project-level skills** (specific to current directory):
.agents/skills/
Skills added via `/add-skill` are installed in `.agents/skills/` of your current workspace, making them available for that project.
To add skills globally, manually place skill directories in `~/.openhands/skills/`.
SDK users programmatically load skills:
from openhands.sdk import Skill
# Load from a directory
skill = Skill.load("/path/to/skill")
# Load all skills from a directory
skills = Skill.load_all("/path/to/skills")
See the [SDK Skills Guide](https://docs.openhands.dev/sdk/guides/skill) for more details.
Skills are stored in:
.agents/skills/
The GUI provides a visual interface for managing skills, but skills can also be added manually by placing them in this directory.
OpenHands Cloud provides a centralized skill library accessible through the web interface. Skills can be:
* Added from the official registry with one click
* Imported from your connected repositories
* Shared across your team or organization
See the [Cloud UI documentation](https://docs.openhands.dev/openhands/usage/cloud/cloud-ui) for details.
Manual Installation
You can also manually install skills by copying skill directories into the appropriate location.
For Project-Level Skills
- Create the skills directory if it doesn't exist:
mkdir -p .agents/skills
- Copy or clone the skill directory:
# Using git
git clone https://github.com/OpenHands/extensions temp-clone
cp -r temp-clone/skills/codereview .agents/skills/
rm -rf temp-clone
# Or download and extract manually
- Verify the skill structure:
ls .agents/skills/codereview/SKILL.md
For User-Level Skills (CLI Only)
- Create the global skills directory:
mkdir -p ~/.openhands/skills
- Add skills to this directory:
cp -r /path/to/skill ~/.openhands/skills/
Skills in ~/.openhands/skills/ are available in all your conversations when using the CLI.
Verifying Installation
After adding a skill, verify it's available:
- Check the file exists: The skill directory should contain at least a
SKILL.mdfile
ls .agents/skills/your-skill/SKILL.md
- Test the trigger: For keyword-triggered skills, use one of the trigger words in your prompt:
Help me set up kubernetes
- Check skill loading: OpenHands will indicate when a skill is loaded in response to your prompt
Skill Updates
To update a skill to the latest version:
- Remove the old version:
rm -rf .agents/skills/skill-name
- Add the updated version:
/add-skill https://github.com/OpenHands/extensions/tree/main/skills/skill-name
Or manually pull updates if you cloned the skill repository.
Authentication for Private Skills
The /add-skill command automatically uses the GITHUB_TOKEN environment variable to access private repositories via the GitHub API.
For manual git clone operations (such as when cloning directly into .agents/skills/), you'll need to handle authentication differently—typically using SSH keys or embedding a personal access token in the clone URL.
Using /add-skill with private repositories:
- Set the
GITHUB_TOKENenvironment variable:
export GITHUB_TOKEN=your_github_token
- Use
/add-skillas normal with private repository URLs
The command will automatically use the token for authentication.
Skill Conflicts
If a skill with the same name already exists, OpenHands will warn you before overwriting. To resolve conflicts:
- Rename the existing skill: Move or rename the existing skill directory
- Choose a different installation location: Install at user-level vs project-level
- Overwrite: Confirm the overwrite when prompted
Next Steps
- Browse available skills in the official registry
- Create your own skills for custom workflows
- Learn about keyword triggers to make skills activate automatically
- Understand skill structure for the AgentSkills format
Monitor skill performance in production using logging, evaluation metrics, dashboarding, and automated feedback aggregation.
After creating and deploying a skill, monitor its performance to ensure it works correctly in production. This is particularly important for skills used in automated workflows like CI/CD pipelines.
The Monitoring Workflow
Production skill monitoring follows a four-part process:
- Logging - Record agent behavior during skill execution
- Evaluating - Measure performance using relevant metrics
- Dashboarding - Visualize metrics over time
- Aggregating - Use feedback to improve the skill
Logging Agent Behavior
OpenHands includes OpenTelemetry-compatible instrumentation via the Laminar library. Set up logging to capture agent traces during skill execution.
For SDK Users
Set the LMNR_PROJECT_API_KEY environment variable to send traces to Laminar, or configure any OpenTelemetry-compatible backend:
export LMNR_PROJECT_API_KEY="your-api-key"
See the SDK Observability Guide for detailed configuration options including Honeycomb, Jaeger, Datadog, and other OTLP-compatible backends.
For GitHub Actions
When using skills in GitHub workflows, add the API key to your action configuration. See the PR review action example for reference.
Evaluating Performance
Define metrics that reflect whether your skill is working correctly. Effective metrics measure actual outcomes rather than intermediate steps.
Example: PR Review Skill
For a code review skill, measure suggestion acceptance rate:
suggestion_accuracy = ai_suggestions_reflected / ai_suggestions
Track:
- Number of suggestions made by the agent
- Number of suggestions incorporated by developers
Implementation Approach
- Create an evaluation workflow - Run after the main task completes (e.g., after PR merge)
- Collect relevant data - Agent output, human responses, final results
- Use LLM as judge - Feed data into a prompt that calculates metrics
Example evaluation prompt excerpt:
### ai_suggestions
Count items where the body contains an actionable code suggestion
(look for code blocks, "suggestion:", specific changes to make).
Do NOT count general praise or approval-only comments.
### ai_suggestions_reflected
Count suggestions that were incorporated. A suggestion is "reflected" if:
1. A human response indicates the suggestion was implemented, OR
2. The suggestion appears in the final diff
See the evaluation action example for a complete implementation.
Dashboarding Metrics
Visualize metrics over time to identify trends. With Laminar or similar platforms, create SQL queries that aggregate evaluation results.
Track:
- Metric trends (improving or degrading)
- Performance across different contexts (repos, file types, etc.)
- Comparison between prompt variations or models
Aggregating Feedback for Improvement
Use language models to analyze patterns in evaluation results and suggest skill improvements.
Process
- Collect evaluation data - Aggregate analyses from recent runs
- Provide current skill content - Include the existing SKILL.md
- Use a reasoning model - Feed both into a long-context model (Gemini-2-Pro, Claude 3.5 Sonnet, etc.)
- Extract actionable suggestions - Review model output for concrete improvements
Example Output
Example output from aggregation:
### Issue: Context-Unaware Suggestions
The agent suggests technically correct changes that conflict with
repository conventions (e.g., suggesting integration tests when the
repo uses mocks).
Frequency: ~15% of suggestions
Recommendation: Add repo-specific testing philosophy to references/
Deployment in Automated Workflows
Skills can run automatically in CI/CD pipelines. The OpenHands Extensions repository includes example GitHub Actions for common automation patterns.
Common Automation Use Cases
- PR review - Run code review skills when PRs are marked "ready for review"
- Issue triage - Classify and label new issues
- Code generation - Generate boilerplate or documentation
- Security scanning - Check for vulnerabilities and suggest fixes
See the GitHub Workflows guide for SDK-based automation examples.
Best Practices
Select metrics that reflect real-world outcomes, not just intermediate steps.
Good metrics:
- Suggestion acceptance rate (for code review)
- Issue classification accuracy (for triage)
- Time to resolution (for bug fixing)
Poor metrics:
- Number of suggestions made
- Lines of code generated
- Tokens consumed
Begin with basic logging before implementing complex evaluation pipelines.
- Set up OpenTelemetry logging
- Review traces manually to understand agent behavior
- Identify patterns in successes and failures
- Design metrics based on observed patterns
- Automate evaluation
Use evaluation results to make targeted improvements:
- Low accuracy → Review skill instructions for clarity
- Inconsistent behavior → Add more specific examples
- Context errors → Expand references/ with domain knowledge
- Repetitive failures → Create scripts for deterministic tasks
Track performance across different contexts:
- By repository - Different repos may need different approaches
- By file type - Skills may work better on certain languages
- By time - Identify degradation or improvement trends
- By model - Compare different LLM backends
Further Reading
- SDK Observability Guide - Detailed OpenTelemetry configuration
- GitHub Workflows - Automate skills in CI/CD
- Hooks Guide - Event-driven skill execution
- Creating Skills - Skill creation fundamentals
Path-triggered rules are skills that OpenHands injects deterministically whenever the agent reads, edits, or creates a file whose path matches a glob pattern. They behave like Claude Code "rules" — guaranteed to load for the files they scope, with no reliance on the model choosing them.
Usage
A path-triggered rule is an ordinary skill with a paths: glob in its frontmatter. Whenever the
agent touches a file (reads, edits, or creates it) whose workspace-relative path matches one of
those globs, the rule's content is folded into the tool result the agent reads next — so the guidance
is guaranteed to be present exactly when the agent is working on the matching file.
Unlike keyword-triggered skills, rules are not advertised in
<available_skills> and cannot be invoked by the model. They add zero baseline cost to the
context window: nothing is loaded until a matching file is actually touched, and each rule is injected
only once per conversation.
Use path-triggered rules for scoped conventions that should apply automatically when specific files
are edited — e.g. "validate all request inputs with zod" for src/api/**/*.ts, or "keep migrations
reversible" for db/migrations/**.
Frontmatter Syntax
Frontmatter is required for path-triggered rules. Enclose it in triple dashes (---) at the top of
the file, above the guidelines.
| Field | Description | Required | Default |
|---|---|---|---|
paths |
Glob patterns (YAML list or comma-separated string) that scope the rule. | Yes | None |
A file that declares both paths: and triggers: becomes a path-triggered rule — paths: wins.
This keeps rules deterministic and out of the model-invocable catalog.
Glob Semantics
Patterns use gitignore-style matching against the workspace-relative POSIX path (matching is case-sensitive):
| Pattern | Matches |
|---|---|
** |
Any number of path segments, including zero (crosses /). |
* |
Any run of characters within a single path segment. |
? |
A single non-separator character. |
*.ts (no slash) |
The basename at any depth — equivalent to **/*.ts. |
* also matches leading-dot files (e.g. src/* matches src/.env).
Example
Here's a rule located at .agents/skills/api-validation.md:
---
paths:
- "src/api/**/*.ts"
- "**/*.route.ts"
---
API RULE: validate all request inputs with zod before using them.
Reject unknown fields and return a 400 with the validation error.
When the agent creates or edits src/api/users.ts, the rule content is appended to that tool result
inside an <EXTRA_INFO> block:
<EXTRA_INFO>
The following rule applies because a file you touched matches "src/api/**/*.ts". Follow it when working with matching files.
Rule location: /repo/.agents/skills/api-validation.md
API RULE: validate all request inputs with zod before using them.
Reject unknown fields and return a 400 with the validation error.
</EXTRA_INFO>
Path-triggered rules load from the same skills directories as other skills (.agents/skills/,
.openhands/skills/, …). They are repo-scoped: touching a file outside the workspace never fires a
rule. Injection is available for local conversations; ACP-backed conversations do not inject path
rules because the ACP server owns tool execution.
See the SDK guide for the programmatic PathTrigger API.
Organizations and users can define skills that apply to all repositories belonging to the organization or user.
Usage
These skills can be any type of skill and will be loaded accordingly. However, they are applied to all repositories belonging to the organization or user.
Add a .agents repository under the organization or user and create a skills directory and place the
skills in that directory.
For GitLab organizations, use openhands-config as the repository name instead of .agents, since GitLab doesn't support repository names starting with non-alphanumeric characters.
Example
General skill file example for organization Great-Co located inside the .agents repository:
skills/org-skill.md:
* Use type hints and error boundaries; validate inputs at system boundaries and fail with meaningful error messages.
* Document interfaces and public APIs; use implementation comments only for non-obvious logic.
* Follow the same naming convention for variables, classes, constants, etc. already used in each repository.
For GitLab organizations, the same skill would be located inside the openhands-config repository.
User Skills When Running OpenHands on Your Own
When running OpenHands on your own, you can place skills in the ~/.agents/skills/ folder on your local
system and OpenHands will always load them for all your conversations. Repo-level overrides live in .agents/skills/.
User skills from `~/.agents/skills/` are loaded automatically — no extra configuration needed.
When running OpenHands via Docker, the agent-server container cannot see your host filesystem by default.
You need to mount your local skills directory into the sandbox using the `SANDBOX_VOLUMES` environment variable:
docker run -it --rm --pull=always \
-e SANDBOX_VOLUMES="$HOME/.agents/skills:/home/openhands/.agents/skills:ro" \
-e AGENT_SERVER_IMAGE_REPOSITORY=ghcr.io/openhands/agent-server \
-e AGENT_SERVER_IMAGE_TAG=1.26.0-python \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.openhands:/.openhands \
-p 3000:3000 \
--add-host host.docker.internal:host-gateway \
--name openhands-app \
docker.openhands.dev/openhands/openhands:1.8
Mount into `~/.agents/skills` inside the container (not `~/.openhands/skills`). Mounting
into `~/.openhands/skills` would overwrite the public skills cache and prevent built-in
skills from loading.
You can store your skills in any host directory (e.g., `~/my-skills/`) and mount them
to `~/.agents/skills` in the sandbox:
-e SANDBOX_VOLUMES="$HOME/my-skills:/home/openhands/.agents/skills:ro"
If you also need to mount a workspace, use a comma-separated list:
-e SANDBOX_VOLUMES="$HOME/project:/workspace:rw,$HOME/.agents/skills:/home/openhands/.agents/skills:ro"
See the [SANDBOX\_VOLUMES documentation](https://docs.openhands.dev/openhands/usage/sandboxes/docker#using-sandbox_volumes) for more details
on the mount format.
