Source: https://docs.aivax.net/docs/inference/skills.html

# Skills

Skills (also known as abilities) are instructions that your agent loads on demand to perform specific tasks better. Use them for specialized behavior that only some conversations need, instead of keeping every rule in the system instructions.

The agent loads a skill only when it is relevant to the current task. It does this through the `read_skill` tool, which adds the skill's instructions to the conversation context.

## How do skills work?

Each skill is identified by a slug and a brief description of what it does and when to use it. Your account can have many skills, and each [AI Gateway](https://docs.aivax.net/docs/inference/ai-gateways/concepts.md) enables only the subset it needs.

At inference time, the flow is:

1. AIVAX lists the slug and description of each skill enabled in the gateway in the model's system instructions, and adds the `read_skill` function to the context. The full instructions are not included at this point.
2. When a task matches a skill, the model calls `read_skill` with an array of skill slugs.
3. The call returns the instructions of the matching skills.

The model can activate more than one skill when a task spans multiple domains. When the active task changes, it can call `read_skill` again with a different list.

For this to work, the chosen base model must support **function calls** and **system instructions**.

- If your model does not support function calls, choose a model with native tool calling. The [function interpreter](https://docs.aivax.net/docs/inference/chat-completions/function-interpreter.md) is deprecated.
- If your model does not support system instructions, consider using the `No system instructions` flag, which provides system instructions as a user message.

Larger models tend to follow instructions and function calls very strictly. Run tests to confirm that your model loads the right skills and switches them when the task changes.

## Structure and operation

A skill has `slug`, `description`, `instructions`, and `options`:

- `slug`: The technical identifier used by the account. It must be 64 characters or fewer, using letters, numbers, underscores, periods, or hyphens.
- `description`: The text that helps the model decide when to load the skill. Explain the usage scenario instead of repeating the name.
- `instructions`: The full content inserted when the skill is activated.

Write the description as a routing rule. A description like “legal skill” is weak because it doesn’t say when to use it. A better description would be “use when the user asks for analysis, review, or explanation of contractual clauses in simple language.”

The instructions, on the other hand, should be operational: explain how to respond, what questions to ask when data is missing, which tools may be useful, what limits must be respected, and the expected final format. The model reads the description to choose the skill and reads the instructions to perform the task.

`allowedToolsNames` associates tools with a skill, such as `web_search`, `open_url`, `generate_image`, or `generate_web_page`. When the gateway hides tools without a skill, these tools become available after the model activates the skill with `read_skill`.

Only the skills from the most recent `read_skill` call are active. Use the general always-visible tool list for tools that must stay available regardless of the active skill.

### Import and export skills

Skills can be imported and exported in JSONL. This format is useful for versioning skills, migrating settings between accounts, keeping a set of skills in a repository, or reviewing changes before publishing. Each line must represent a skill with at least `slug` and `instructions`; `description` and `options` can complement the configuration. When importing a skill with an existing `slug`, AIVAX updates the corresponding skill instead of creating a duplicate.

## How to write skills?

Effective skills have a clear routing description and specific instructions. Use the following guidelines.

### Skill structure

A well-written skill should contain:

1. **Clear, descriptive slug**: Use a short slug that immediately identifies the purpose of the skill, such as `python_code_analysis`, `customer_support`, or `technical_translation`.

2. **Concise description**: Provide a brief description (1–2 sentences) that explains when the skill should be activated. This description is crucial because the model uses it to decide whether to load the skill.

3. **Detailed instructions**: The actual instructions should include:
   - Clear objectives of the task
   - Expected response format
   - Specific rules to follow
   - Examples where appropriate
   - Important constraints or limitations

### Best practices

- **Be specific**: Avoid vague instructions. Instead of “be helpful,” say “provide step-by-step explanations with code examples.”
- **Use imperative language**: Start sentences with action verbs (analyze, explain, compare, list).
- **Keep the scope limited**: Each skill should focus on a specific knowledge area or type of task.
- **Test iteratively**: Refine your skills based on how the model responds in practice.
- **Avoid redundancy**: Do not repeat information already present in the base system instructions.

### Skill example

- Name: Code Performance Analysis
- Description: Use when the user asks for performance analysis, optimization, or bottleneck identification in code.
- Instructions:

```markdown
- Analyze the provided code identifying possible performance bottlenecks
- Consider time complexity (Big O) and memory usage
- Suggest specific optimizations with code examples
- Explain the impact of each proposed optimization
- Prioritize readability and maintainability alongside performance
```

## When to use skills?

Skills are most useful when the agent needs specialized behavior only in some conversations.

### Ideal scenarios

**1. Domain-specific expertise**
- Technical terminology specific to an industry
- Compliance with regulations or standards
- Specific methodologies (Scrum, ITIL, SOC 2, etc.)

**2. Tone or style shift**
- Formal vs. casual service
- Technical vs. simplified communication
- Different personas or roles

**3. Complex, structured processes**
- Multi-step workflows
- Analyses that follow specific frameworks
- Document generation with strict formats

**4. Tasks that require extensive context**
- When instructions are too long to include every time
- Knowledge that is only occasionally relevant
- Multiple mutually exclusive rule sets

### When NOT to use skills

- **Permanent instructions**: If instructions should always be active, put them in the base system instructions.
- **Simple tasks**: For direct answers that don’t require special context.
- **General knowledge**: Information the model already knows well does not need to be reinforced via skills.
- **Too few or too many skills**: Aim for 3–10 skills. Less than that, consider using base instructions. More than that can confuse the model.

### Comparison: Skills vs. System Instructions

| Aspect | Skills | System Instructions |
|--------|--------|----------------------|
| When to apply | On demand, when relevant | Always active |
| Ideal size | Can be extensive | Should be concise |
| Context switching | Yes, can alternate | No, fixed |
| Token usage | Economical (only when needed) | Constant |
| Best for | Specialized knowledge | Base agent behavior |

### Implementation tips

- **Start small**: Implement 2–3 skills initially and expand as needed.
- **Monitor usage**: Check that the model is activating skills correctly.
- **Avoid overlap**: Skills with similar descriptions can confuse the model.
- **Test transitions**: Ensure the model switches skills when appropriate.

## Combine skills with RAG and pipelines

Use skills together with [collections](https://docs.aivax.net/docs/rag/collections.md) when the task needs searchable knowledge, and with [pipelines](https://docs.aivax.net/docs/inference/chat-completions/processing-pipeline.md) when it needs event-time policy or message rewriting. For broader background, see the [Prompt Engineering Guide](https://www.promptingguide.ai/), [Building effective agents](https://www.anthropic.com/index/building-effective-agents), and the [AI Gateway Documentation](https://docs.aivax.net/docs/inference/ai-gateways/concepts.md).
