SkillsCapability API Reference
SkillsCapability is the entry point. Pass it to an agent's capabilities=[...].
It is a composite over
pydantic-ai-harness's Skills: harness
discovers and validates the skill packages and renders their instructions, while this capability
syncs remote registries, indexes bundled files, resolves ${SKILL_DIR}, and adds Python-defined
skills. See Core Concepts for the division of labour.
Bases: AbstractCapability[AgentDepsT]
Expose Agent Skills — local, remote, or Python-defined — to a Pydantic AI agent.
Every skill becomes its own deferred capability: the model sees names and descriptions
up front and pulls a skill's instructions in with load_capability. Skills discovered
on disk are validated and rendered by pydantic-ai-harness; this capability adds
remote sources, the bundled-file tools, and programmatic skills on top.
Discovery is a snapshot taken during construction, matching harness's own semantics.
Call registry.sync() and build a new SkillsCapability to pick up changes.
Example
from pydantic_ai import Agent
from pydantic_ai_skills import GitSkillsRegistry, SkillsCapability
agent = Agent(
'anthropic:claude-sonnet-4-6',
capabilities=[
SkillsCapability(
'.agents/skills',
registries=[
GitSkillsRegistry(
'https://github.com/anthropics/skills',
path='skills',
),
],
),
],
)
Source code in pydantic_ai_skills/capability.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
__init__
__init__(directories: str | Path | Sequence[str | Path] = (), *, registries: Sequence[SkillRegistry] = (), skills: Sequence[Skill | SkillWrapper[Any]] = (), include: Collection[str] | None = None, exclude: Collection[str] | None = None, script_executor: SkillScriptExecutor | None = None, exclude_resources: Sequence[str] | None = None, resources: bool = True, scripts: bool = True, require_loaded: bool = True, resolve_skill_dir: bool = True, list_bundled_files: bool = True, id: str | None = None) -> None
Build the deferred catalog from libraries, registries and Python-defined skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
str | Path | Sequence[str | Path]
|
One skill-library path or a sequence of them. A library is the parent of the skill packages, not a skill package itself. |
()
|
registries
|
Sequence[SkillRegistry]
|
Registries to sync into local libraries before discovery. See
|
()
|
skills
|
Sequence[Skill | SkillWrapper[Any]]
|
Python-defined skills, which join the same deferred catalog. |
()
|
include
|
Collection[str] | None
|
Exact names to expose. Omit to expose all discovered skills. |
None
|
exclude
|
Collection[str] | None
|
Exact names to omit. Cannot be combined with |
None
|
script_executor
|
SkillScriptExecutor | None
|
Executor for bundled scripts. Defaults to
|
None
|
exclude_resources
|
Sequence[str] | None
|
Extra glob patterns to exclude from resource discovery, on
top of
|
None
|
resources
|
bool
|
Register the |
True
|
scripts
|
bool
|
Register the |
True
|
require_loaded
|
bool
|
Refuse bundled-file calls for a skill the model has not loaded, keeping files behind the same boundary as the skill's instructions. |
True
|
resolve_skill_dir
|
bool
|
Substitute |
True
|
list_bundled_files
|
bool
|
Append a "Bundled files" section naming a skill's
resources and scripts to its instructions, so the model reads the names
the file tools expect instead of inferring them from prose. Turn off for
skills whose |
True
|
id
|
str | None
|
Stable identifier for the capability that carries the bundled-file tools. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in pydantic_ai_skills/capability.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
skill_names
property
skill_names: list[str]
Names of the skills exposed to the model, sorted.
apply
apply(visitor: Callable[[AbstractCapability[AgentDepsT]], None]) -> None
Visit this capability and each skill it exposes as a deferred leaf.
Unlike a pure container, this visits self as well. It has to: pydantic-ai builds
the run's capability registry from apply, and the toolset returned by
get_toolset is owned by whichever capability that registry maps it to. Skipping
self leaves the bundled-file tools with no registered owner, which fails the run
the first time the model calls one.
Only visited when this capability actually contributes a toolset, so a
SkillsCapability over skills that ship no files stays a pure container.
Source code in pydantic_ai_skills/capability.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
visit_and_replace
visit_and_replace(visitor: Callable[[AbstractCapability[AgentDepsT]], AbstractCapability[AgentDepsT] | None]) -> AbstractCapability[AgentDepsT] | None
Rewrite the leaves in place, keeping this capability as their container.
Source code in pydantic_ai_skills/capability.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
get_toolset
get_toolset() -> AgentToolset[AgentDepsT] | None
Return the bundled-file toolset, or None when no skill ships files.
This has to come from the container itself rather than from a leaf: pydantic-ai
collects toolsets by calling get_toolset() on a container's direct children
(see CombinedCapability.get_toolset), and does not recurse through apply the
way it does when building the capability-id registry. A toolset parked on a leaf
would never be registered.
The tools stay always-on while each skill is deferred, which is deliberate: the
model needs them the moment it loads a skill, and require_loaded — not tool
visibility — is what keeps a skill's files behind its instructions.
Source code in pydantic_ai_skills/capability.py
518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
from_spec
classmethod
from_spec(*, directories: list[str] | str | None = None, include: list[str] | None = None, exclude: list[str] | None = None, exclude_resources: list[str] | None = None, resources: bool = True, scripts: bool = True, require_loaded: bool = True, resolve_skill_dir: bool = True, list_bundled_files: bool = True, id: str | None = None) -> AbstractCapability[Any]
Create from a YAML/JSON agent spec.
Only serializable arguments are supported. Registries, programmatic skills, and custom script executors cannot be expressed in a spec; construct the capability in Python for those.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directories
|
list[str] | str | None
|
Skill-library paths, as strings. |
None
|
include
|
list[str] | None
|
Exact skill names to expose. Cannot be combined with |
None
|
exclude
|
list[str] | None
|
Exact skill names to omit. Cannot be combined with |
None
|
exclude_resources
|
list[str] | None
|
Extra glob patterns to exclude from resource discovery. |
None
|
resources
|
bool
|
Register the |
True
|
scripts
|
bool
|
Register the |
True
|
require_loaded
|
bool
|
Refuse bundled-file calls for a skill that is not loaded. |
True
|
resolve_skill_dir
|
bool
|
Substitute |
True
|
list_bundled_files
|
bool
|
Append a "Bundled files" section naming a skill's resources and scripts to its instructions. |
True
|
id
|
str | None
|
Stable identifier for the capability carrying the bundled-file tools. |
None
|
Source code in pydantic_ai_skills/capability.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
get_serialization_name
classmethod
get_serialization_name() -> str | None
Return the name used to reference this capability in agent specs.
Source code in pydantic_ai_skills/capability.py
533 534 535 536 | |
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
directories |
str \| Path \| Sequence[str \| Path] |
() |
Skill-library paths. A library is the parent of the skill packages. |
registries |
Sequence[SkillRegistry] |
() |
Remote sources, synced to local libraries at construction. |
skills |
Sequence[Skill \| SkillWrapper] |
() |
Skills defined in Python. |
include |
Collection[str] \| None |
None |
Exact names to expose. Cannot be combined with exclude. |
exclude |
Collection[str] \| None |
None |
Exact names to omit. Cannot be combined with include. |
script_executor |
SkillScriptExecutor \| None |
None |
Where bundled scripts run. Defaults to local subprocesses. |
exclude_resources |
Sequence[str] \| None |
None |
Extra glob patterns excluded from resource discovery. |
resources |
bool |
True |
Register read_skill_resource. |
scripts |
bool |
True |
Register run_skill_script. |
require_loaded |
bool |
True |
Refuse bundled-file calls for a skill the model has not loaded. |
resolve_skill_dir |
bool |
True |
Substitute ${SKILL_DIR} / ${CLAUDE_SKILL_DIR} in instructions. |
id |
str \| None |
None |
Stable identifier for the capability carrying the file tools. |
At least one of directories, registries or skills must be given.
Tools
SkillsCapability registers two tools. The catalog and instruction loading are Pydantic AI's own
load_capability, not something this package provides.
| Tool | Signature | Purpose |
|---|---|---|
read_skill_resource |
(skill_name, resource_name, args=None) |
Read a bundled text file, or invoke a callable resource. |
run_skill_script |
(skill_name, script_name, args=None) |
Execute a bundled script through the configured executor. |
Both are omitted entirely when no skill ships files of the matching kind.
Agent specs
SkillsCapability works with Pydantic AI's
YAML and JSON agent specs:
model: anthropic:claude-sonnet-4-6
capabilities:
- SkillsCapability:
directories: ['./skills']
include: ['pdf-processing']
scripts: false
agent = Agent.from_file('agent.yaml', custom_capability_types=[SkillsCapability])
Registries, programmatic skills and custom executors cannot be expressed in a spec — construct the capability in Python for those.