skill#

class baf.reasoning.skill.Skill(content, name=None, description=None)[source]#

Bases: object

A named, markdown-based playbook the reasoning loop can inject as system context.

A Skill is a small, composable system prompt: a name, an optional description, and the markdown content to splice into the LLM’s system message at run time. Skills can be loaded from a string, from a single .md file, or from a folder of .md files.

Frontmatter (an optional --- block at the top of the file) is parsed as plain key: value lines. Recognised keys: name, description.

Parameters:
  • content (str) – the markdown text of the skill, optionally prefixed by a --- ... --- frontmatter block.

  • name (str) – the skill name. If not provided, falls back to frontmatter['name'], then to the first H1 in the body.

  • description (str) – a short description. If not provided, falls back to frontmatter['description'].

name#

the skill name.

Type:

str

description#

the optional description.

Type:

Optional[str]

content#

the markdown body, with any frontmatter stripped.

Type:

str

classmethod from_file(path)[source]#

Load a Skill from a markdown file.

If neither frontmatter nor a leading H1 supplies a name, the file’s stem (filename without extension) is used.

Parameters:

path (str) – path to a .md file.

Returns:

the loaded skill.

Return type:

Skill

classmethod from_folder(folder)[source]#

Load every *.md file in folder (non-recursive) as a Skill.

Parameters:

folder (str) – path to a folder containing markdown files.

Returns:

the loaded skills, sorted by filename.

Return type:

list[Skill]

to_prompt()[source]#

Render the skill as a chunk of system-prompt markdown.

Returns:

"## Skill: {name}\n{description?}\n\n{content}" — the description line is omitted when no description is set.

Return type:

str

baf.reasoning.skill._extract_h1_title(body)[source]#

Return the text of the first H1 (’# Title’) in body, or None.

baf.reasoning.skill._parse_frontmatter(content)[source]#

Parse a leading --- ... --- frontmatter block.

Frontmatter is parsed as plain key: value lines (one per line). No YAML dependency is used. If the block is malformed (e.g., only an opening delimiter, or no recognisable key/value pairs), a warning is logged and the full content is returned untouched as the body.

Parameters:

content (str) – the raw markdown text.

Returns:

a (metadata, body) pair. metadata is empty if no frontmatter was found.

Return type:

tuple[dict, str]