# createSkillsMiddleware

> **Function** in `deepagents`

📖 [View in docs](https://reference.langchain.com/javascript/deepagents/middleware/createSkillsMiddleware)

Create backend-agnostic middleware for loading and exposing agent skills.

This middleware loads skills from configurable backend sources and injects
skill metadata into the system prompt. It implements the progressive disclosure
pattern: skill names and descriptions are shown in the prompt, but the agent
reads full SKILL.md content only when needed.

Skills are loaded once per thread and stored in state. To pick up skills
added, edited, or deleted since then, set `skillsMetadata` to `null`; the
next model call reloads every source:

```ts
await agent.updateState(config, { skillsMetadata: null });
// or as part of the next run's input
await agent.invoke({ messages, skillsMetadata: null }, config);
```

Loading happens in `beforeModel`, so the reload is served by the next model
call rather than the next run. A middleware of your own can therefore
invalidate from any hook — including mid-run, from `afterModel` — and see
the fresh list on the following call. See skillsMetadataValue.

## Signature

```javascript
createSkillsMiddleware(options: SkillsMiddlewareOptions): AgentMiddleware<StateSchema<__type>, undefined, unknown, readonly ClientTool | ServerTool[], readonly []>
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `options` | `SkillsMiddlewareOptions` | Yes | Configuration options |

## Returns

`AgentMiddleware<StateSchema<__type>, undefined, unknown, readonly ClientTool | ServerTool[], readonly []>`

AgentMiddleware for skills loading and injection

## Examples

```typescript
const middleware = createSkillsMiddleware({
  backend: new FilesystemBackend({ rootDir: "/" }),
  sources: ["/skills/user/", "/skills/project/"],
});
```

---

[View source on GitHub](https://github.com/langchain-ai/deepagentsjs/blob/7839cda00a58e023520ece4c31ecc43fa2d589f5/libs/deepagents/src/middleware/skills.ts#L819)