trading_agent.skills.skill
¶
One skill: a folder holding a SKILL.md file and, optionally, scripts/ and references/.
SKILL.md follows the open Agent Skills format that Claude Code and Hermes use: YAML frontmatter between two --- lines, then Markdown instructions.
name: opening-range-breakout description: How to trade the first 15-minute range of an NSE stock. requires: programs: [python3] environment: [SOME_API_KEY]
# Opening range breakout ...
A skill can say what it needs with requires (programs and environment variables), or with Hermes's prerequisites (commands and env_vars). A skill whose needs are missing is hidden from the desk.
Typical usage example:
skill = SkillParser().parse(Path('workspace/shared/skills/installed/opening-range-breakout'), 'installed')
SkillFormatError
¶
Bases: ValueError
A SKILL.md file is missing, or its frontmatter is not valid.
Skill
dataclass
¶
One parsed skill.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The skill's name, lower-case letters, digits and hyphens. |
description |
str
|
One or two sentences saying when to use it, shown in the skills index. |
body |
str
|
The Markdown instructions after the frontmatter. |
directory |
Path
|
The skill's folder. |
origin |
str
|
"installed" for the user's skills, "agent" for skills the desk wrote. |
required_programs |
tuple[str, ...]
|
Programs that must be on the PATH. |
required_environment |
tuple[str, ...]
|
Environment variables that must be set. |
bundled_files
¶
The files in the skill's scripts/ and references/ folders.
Returns:
| Type | Description |
|---|---|
list[Path]
|
The files, sorted by path. |
Source code in src/trading_agent/skills/skill.py
SkillParser
¶
Reads SKILL.md files.
parse
¶
Reads the skill in a folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Path
|
The skill's folder. |
required |
origin
|
str
|
"installed" or "agent". |
required |
Returns:
| Type | Description |
|---|---|
Skill
|
The skill. |
Raises:
| Type | Description |
|---|---|
SkillFormatError
|
SKILL.md is missing, has no frontmatter, or its name or description is not valid. |
Source code in src/trading_agent/skills/skill.py
check_name
¶
Checks a skill name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name. |
required |
Raises:
| Type | Description |
|---|---|
SkillFormatError
|
The name is not 1 to 64 lower-case letters, digits and hyphens starting with a letter or digit. |
Source code in src/trading_agent/skills/skill.py
check_description
¶
Checks a skill description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str
|
The description. |
required |
Raises:
| Type | Description |
|---|---|
SkillFormatError
|
The description is empty or longer than 1,024 characters. |
Source code in src/trading_agent/skills/skill.py
frontmatter_text
¶
Writes the frontmatter for a new skill.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The skill's name. |
required |
description
|
str
|
Its description. |
required |
required_programs
|
list[str]
|
Programs it needs. |
required |
required_environment
|
list[str]
|
Environment variables it needs. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The frontmatter, including both --- lines. |