> Discover all available pages from the documentation index: https://mastra.ai/llms.txt

# `createSkill()`

Creates an inline skill that can be passed directly to an agent's `skills` config without a filesystem or workspace.

The returned object implements the `Skill` interface and works anywhere a filesystem-discovered skill works.

## Usage example

```typescript
import { createSkill } from '@mastra/core/skills'

const reviewSkill = createSkill({
  name: 'code-review',
  description: 'Use when reviewing code changes.',
  instructions: `
    When reviewing code:
    1. Check for correctness
    2. Check for style consistency
    3. Look for potential bugs
  `,
  references: {
    'checklist.md': '# Review Checklist\n- No unused imports\n- Error handling present',
  },
})
```

## Parameters

**name** (`string`): Unique skill name. Used as the identifier when agents activate the skill. Must be a valid slug (lowercase, hyphens allowed).

**description** (`string`): Short description shown to the agent in the system message. Helps the agent decide when to use the skill.

**instructions** (`string`): The full skill instructions in markdown. Loaded into the conversation when the agent activates the skill.

**references** (`Record<string, string>`): Supporting documents the agent can read with the skill\_read tool. Keys are filenames, values are file contents.

**license** (`string`): SPDX license identifier for the skill.

**compatibility** (`unknown`): Compatibility requirements. The Agent Skills spec leaves this flexible — can be a string array, object, or any structure your tooling expects.

**user-invocable** (`boolean`): Whether end users can invoke this skill directly. Defaults to undefined (agent decides).

**metadata** (`Record<string, unknown>`): Arbitrary metadata attached to the skill.

## Return value

Returns an `InlineSkill` object that implements the `Skill` interface:

```typescript
interface InlineSkill extends Skill {
  __inline: true
  __referenceContents: Record<string, string>
}
```

The skill is assigned a synthetic path of `inline/<name>` (e.g., `inline/code-review`).

## Validation

`createSkill()` validates inputs using the same rules as filesystem skills:

- `name` is required and must be a valid slug
- `description` is required
- `instructions` is required and non-empty

If validation fails, an `Error` is thrown with details about the invalid fields.

```typescript
// Throws: Invalid skill "": name is required
createSkill({ name: '', description: 'test', instructions: 'test' })
```

## Related

- [Agent skills](https://mastra.ai/docs/agents/skills)
- [Workspace skills](https://mastra.ai/docs/workspace/skills)
- [`.getSkill()` reference](https://mastra.ai/reference/agents/getSkill)
- [`.listSkills()` reference](https://mastra.ai/reference/agents/listSkills)