Skip to content

API Reference parrot.skills.parsers

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.skills.parsers

View source

Skill file parser for .md files with YAML frontmatter.

Parses skill definitions from markdown files that follow the format:

name: resumen description: Resume textos largos en bullet points triggers:

  • /resumen source: authored

Alias SkillDefinition

Re-exported from parrot.skills.models.SkillDefinition.

Alias SkillLoadReject

Re-exported from parrot.skills.models.SkillLoadReject.

Alias SkillSource

Re-exported from parrot.skills.models.SkillSource.

Alias SkillTokenLimitError

Re-exported from parrot.skills.models.SkillTokenLimitError.

Function discover_skills_in_dir

Discover single-file and composite skills in a directory (non-recursive).

Implements the per-directory contract shared by Claude Code, Cursor and Gemini: a directory entry is a skill if it is either a single .md file or a subdirectory containing a SKILL.md entry point.

  • Single-file: {directory}/{name}.md → :func:parse_skill_file.
  • Composite: {directory}/{name}/SKILL.md → :func:parse_skill_directory.

Entries are iterated in sorted order for deterministic discovery. Entries whose name appears in exclude_names are skipped (e.g. the reserved learned subdirectory). Non-.md files and directories lacking a SKILL.md are silently ignored. Malformed skills are logged as warnings and skipped so one bad skill never aborts discovery.

discover_skills_in_dir(directory: Path, logger: logging.Logger = _LOGGER, exclude_names: Iterable[str] = (), *, max_tokens: Optional[int] = None, rejects: Optional[List[SkillLoadReject]] = None) -> List[SkillDefinition]

Parameter Type Default Description
directory Path Directory to scan. Returns an empty list if it does not exist or is not a directory.
logger logging.Logger _LOGGER Logger for malformed-skill warnings.
exclude_names Iterable[str] () Entry names to skip (matched against entry.name).
max_tokens Optional[int] None Optional effective token limit for every discovered skill.
rejects Optional[List[SkillLoadReject]] None Optional collector for records describing skipped skills.

Returns: List[SkillDefinition] — List of successfully parsed :class:~parrot.skills.models.SkillDefinition.

Function parse_skill_directory

Parse a composite skill: {dir}/SKILL.md plus adjacent asset files.

A composite skill is a directory containing a SKILL.md entry point (parsed via :func:parse_skill_file) and zero or more adjacent asset files (scripts, templates, examples). The assets_dir field on the returned :class:~parrot.skills.models.SkillDefinition is set to the directory path so downstream components can enumerate assets.

parse_skill_directory(skill_dir: Path, *, max_tokens: Optional[int] = None) -> SkillDefinition

Parameter Type Default Description
skill_dir Path Path to the skill directory (must contain SKILL.md).
max_tokens Optional[int] None

Returns: SkillDefinition — Parsed and validated SkillDefinition with assets_dir set to skill_dir.

Raises:

  • FileNotFoundError — If SKILL.md is absent in skill_dir.
  • ValueError — If required frontmatter fields are missing from SKILL.md.
  • SkillTokenLimitError — If the skill body exceeds the effective token limit.

Function parse_skill_file

Parse a .md skill file with YAML frontmatter into a SkillDefinition.

parse_skill_file(file_path: Path, *, max_tokens: Optional[int] = None) -> SkillDefinition

Parameter Type Default Description
file_path Path Path to the .md file.
max_tokens Optional[int] None

Returns: SkillDefinition — Parsed and validated SkillDefinition.

Raises:

  • ValueError — If required frontmatter fields are missing.
  • SkillTokenLimitError — If the skill body exceeds the effective token limit.
  • FileNotFoundError — If the file does not exist.

Function resolve_skill_max_tokens

Resolve the explicit, deployment, or class-default skill body limit.

resolve_skill_max_tokens(explicit: Optional[int] = None) -> int

Parameter Type Default Description
explicit Optional[int] None

Returns: int

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally