Skip to content

Skill operations

Modules concerning the skill operations of an LM invoker.

AnthropicSkillOperations(invoker)

Bases: SkillOperations

Handles skill operations for the AnthropicLMInvoker class.

Examples:

  1. Create a skill:
file = Attachment.from_path("path/to/file.zip")
skill = await lm_invoker.skill.create(file=file, name="My Skill")
  1. List skills:
skills = await lm_invoker.skill.list()
  1. Retrieve a skill:
skill = await lm_invoker.skill.retrieve(skill_id)
  1. Delete a skill:
await lm_invoker.skill.delete(skill_id)
  1. Create a new skill version:
file = Attachment.from_path("path/to/file.zip")
skill = await lm_invoker.skill.version.create(skill_id, file=file)
  1. List skill versions:
versions = await lm_invoker.skill.version.list(skill_id)
  1. Retrieve a specific skill version:
version = await lm_invoker.skill.version.retrieve(skill_id, version="v1")
  1. Delete a specific skill version:
await lm_invoker.skill.version.delete(skill_id, version="v1")

Initializes the skill operations.

Parameters:

Name Type Description Default
invoker AnthropicLMInvoker

The LM invoker to use for the skill operations.

required

version cached property

Lazy-initialized version operations sub-namespace.

Returns:

Name Type Description
AnthropicVersionOperations AnthropicVersionOperations

The version operations handler.

create(file, name=None, **kwargs) async

Creates a new skill.

Creates a skill via the Anthropic Skills beta API. Skill creation requires uploading files that include a SKILL.md at the root directory.

Parameters:

Name Type Description Default
file Attachment

The skill file to upload (ZIP archive or markdown file).

required
name str | None

The name of the skill. Defaults to None.

None
version str | None

The version of the skill. Defaults to None.

required
**kwargs Any

Skill creation parameters passed to Anthropic's skills.create.

{}

Returns:

Name Type Description
Skill Skill

The created skill.

delete(skill_id) async

Deletes a skill by ID.

Deletes all versions of the skill first, then deletes the skill itself. Attempting to delete a skill with existing versions will return a 400 error.

Note

The Anthropic Skills beta API may return a 500 error when deleting the latest version. This method handles that by catching server errors on version deletion and still attempting to delete the skill.

Parameters:

Name Type Description Default
skill_id str

The skill identifier to delete.

required

Raises:

Type Description
SkillOperationError

If the skill failed to be deleted.

list() async

Lists the skills.

Uses the Anthropic Skills beta API with automatic pagination via AsyncPageCursor. Includes defensive check to prevent infinite pagination loops.

Returns:

Type Description
list[Skill]

list[Skill]: List of skills.

list_skill() async

Lists the skills.

Returns:

Type Description
list[Skill]

list[Skill]: List of skills.

list_versions(skill_id) async

Lists all versions of a skill by ID.

Parameters:

Name Type Description Default
skill_id str

The skill identifier.

required

Returns:

Type Description
list[Skill]

list[Skill]: List of skill versions.

retrieve(skill_id) async

Retrieves a skill by ID.

Parameters:

Name Type Description Default
skill_id str

The skill identifier.

required

Returns:

Name Type Description
Skill Skill

The retrieved skill.

update(skill_id, file, **kwargs) async

Updates a skill by ID.

Creates a new version of the skill via the Anthropic Skills Versions beta API.

Parameters:

Name Type Description Default
skill_id str

The skill identifier.

required
file Attachment

The skill file to upload (ZIP archive or markdown file).

required
**kwargs Any

Additional keyword arguments passed to Anthropic's versions.create.

{}

Returns:

Name Type Description
Skill Skill

The updated skill with the new version.

SkillOperations(invoker)

Handles skill operations for the BaseLMInvoker class.

Examples:

  1. Create a skill:
file = Attachment.from_path("path/to/file.zip")
skill = await lm_invoker.skill.create(file=file, name="My Skill")
  1. List skills:
skills = await lm_invoker.skill.list()
  1. Retrieve a skill:
skill = await lm_invoker.skill.retrieve(skill_id)
  1. Delete a skill:
await lm_invoker.skill.delete(skill_id)

Initializes the skill operations.

Parameters:

Name Type Description Default
invoker BaseLMInvoker

The LM invoker to use for the skill operations.

required

version cached property

Access version operations sub-namespace.

Returns:

Name Type Description
VersionOperations VersionOperations

The version operations handler.

Raises:

Type Description
NotImplementedError

The version sub-namespace is not supported.

__init_subclass__(**kwargs)

Wrap subclass operation methods to normalize errors.

This keeps base-class methods unchanged while ensuring provider-specific overrides raise SkillOperationError for unexpected failures.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments to initialize the subclass.

{}

create(file, name=None, **kwargs) async

Creates a new skill.

The name must be unique; the provider rejects creation if a skill with the same name already exists.

Parameters:

Name Type Description Default
file Attachment

File attachment of the skill.

required
name str | None

Display name of the skill provided by the user. Defaults to None.

None
**kwargs Any

Additional keyword arguments to create a skill.

{}

Returns:

Name Type Description
Skill Skill

The created skill.

Raises:

Type Description
NotImplementedError

The skill operation is not supported.

delete(skill_id) async

Deletes a skill by ID.

Parameters:

Name Type Description Default
skill_id str

The ID of the skill to delete.

required

Raises:

Type Description
NotImplementedError

The skill operation is not supported.

list() async

Lists the skills.

Returns:

Type Description
list[Skill]

list[Skill]: The list of skills.

Raises:

Type Description
NotImplementedError

The skill operation is not supported.

list_skill() async

Lists the skills.

Returns:

Type Description
list[Skill]

list[Skill]: The list of skills.

Raises:

Type Description
NotImplementedError

The skill operation is not supported.

list_versions(skill_id) async

Lists all versions of a skill by ID.

Parameters:

Name Type Description Default
skill_id str

The ID of the skill.

required

Returns:

Type Description
list[Skill]

list[Skill]: The list of skill versions.

Raises:

Type Description
NotImplementedError

The skill operation is not supported.

retrieve(skill_id) async

Retrieves a skill by ID.

Parameters:

Name Type Description Default
skill_id str

The ID of the skill to retrieve.

required

Returns:

Name Type Description
Skill Skill

The retrieved skill.

Raises:

Type Description
NotImplementedError

The skill operation is not supported.

update(skill_id, file, **kwargs) async

Updates a skill by ID.

Parameters:

Name Type Description Default
skill_id str

The ID of the skill to update.

required
file Attachment

File attachment of the skill (typically a ZIP archive).

required
**kwargs Any

Additional keyword arguments to update a skill.

{}

Returns:

Name Type Description
Skill Skill

The updated skill.

Raises:

Type Description
NotImplementedError

The skill operation is not supported.