Python-Backed Skills vs Markdown Skills in Prime Agent: Architecture and Implementation
Python-backed skills are executable Python packages that install into the IPython kernel for direct async calls, whereas markdown skills provide only textual instructions without runtime code execution.
Python-backed skills extend the standard Agent Skills specification in the PrimeIntellect-ai/prime-agent repository by combining documentation with installable code. While both skill types use SKILL.md front-matter for agent prompts, Python-backed skills ship a complete Python package that binds to the kernel environment, enabling programmatic invocation and CLI integration.
Core Architectural Differences
The distinction between these skill types manifests across six key dimensions:
Package Structure
- Markdown skills: Contain only a
SKILL.mdfile and optional static assets. - Python-backed skills: Require
SKILL.md,pyproject.toml, and a valid Python import layout (src/<import_name>/__init__.py).
Detection Contract
- Markdown skills: Presence of
SKILL.mdis sufficient for discovery. - Python-backed skills: Must satisfy the three-file contract defined in
packages/coding-agent/skills/skill-creator/references/python-skills.md:SKILL.md+pyproject.toml+src/<import_name>/__init__.py.
Kernel Exposure
- Markdown skills: No direct Python callable; the model interprets textual instructions only.
- Python-backed skills: The module installs editable into
~/.prime/agent/kernel-venv(by default) and registers under the import name (skill name with hyphens converted to underscores), exposingawait <import_name>(…)orawait <import_name>.run(…)interfaces.
CLI Integration
- Markdown skills: No shell invocation capability.
- Python-backed skills: Support shell cell invocation (
!<import_name> …) when[project.scripts]defines a console entry point usingrlm.skill:cli.
Dependency Management
- Markdown skills: Zero runtime dependencies.
- Python-backed skills: Declare dependencies in
pyproject.toml; the kernel venv installs them automatically on first load.
Failure Modes
- Markdown skills: Invalid
SKILL.mdresults in the skill being ignored with a warning. - Python-backed skills: Import failures bind the name to a placeholder that raises
RuntimeErroron invocation, preserving kernel stability.
Detection and Installation Process
According to the implementation in packages/coding-agent/docs/skills.md, Prime Agent scans skill locations and reads SKILL.md for the model prompt. When pyproject.toml is detected, the system:
- Validates the Python import layout (
src/<import_name>/__init__.py) - Installs the package in editable mode into the persistent kernel virtual environment
- Registers the module for async calls, transforming hyphens to underscores in the import name (e.g.,
word-countbecomesword_count)
Implementation Examples
Minimal Python-Backed Skill Structure
The word-count skill illustrates the required layout:
word-count/
├── SKILL.md
├── pyproject.toml
└── src/
└── word_count/
└── __init__.py
SKILL.md provides the agent-facing documentation:
---
name: word-count
description: Count word frequencies in text and return the most common words. Use when the user asks for word counts or frequency analysis.
---
# Word Count
Call directly from the kernel:
await word_count("some text to analyze", top=3)
Or from a shell cell:
!word_count "some text to analyze" --top 3
pyproject.toml declares the package metadata and optional CLI entry:
[project]
name = "word-count"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = []
[project.scripts]
word_count = "rlm.skill:cli"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/word_count"]
src/word_count/__init__.py implements the callable API:
from collections import Counter
async def run(text: str, top: int = 5) -> str:
"""Count words in text and return the most common ones."""
counts = Counter(text.lower().split())
return "\n".join(f"{word}: {count}" for word, count in counts.most_common(top))
Using Skills in a Prime Agent Session
Once loaded, Python-backed skills expose multiple invocation patterns:
# Direct async call (module is callable via wrapper)
await word_count("prime agent is awesome", top=3)
# Explicit run method call
await word_count.run("prime agent is awesome", top=3)
# Shell-style invocation from notebook cells
!word_count "prime agent is awesome" --top 3
Markdown-Only Skill Comparison
A standard markdown skill provides only instructions:
---
name: quick-note
description: Append a short note to a local markdown file.
---
# Quick Note
Create a note in `notes.md`:
echo "Your note" >> notes.md
The model can only follow the textual guidance; there is no await quick_note(...) callable or dependency management.
Key Implementation Files
| File | Purpose |
|---|---|
packages/coding-agent/docs/skills.md |
Main skills documentation covering discovery rules and Python-backed skill architecture |
packages/coding-agent/skills/skill-creator/references/python-skills.md |
Contract specification detailing detection requirements, run() conventions, and verification steps |
packages/coding-agent/skills/skill-creator/SKILL.md |
Built-in skill description showing creation patterns for both skill types |
Summary
- Python-backed skills require
SKILL.md,pyproject.toml, andsrc/<import_name>/__init__.pyto satisfy the detection contract. - Packages install into the persistent IPython kernel at
~/.prime/agent/kernel-venvwith editable mode. - Import names convert hyphens to underscores (e.g.,
my-skill→my_skill) for kernel registration. - Skills support both
awaitcalls and shell invocation via[project.scripts]entry points. - Markdown skills provide only documentation with zero runtime footprint and no callable interface.
Frequently Asked Questions
What file structure is required to create a Python-backed skill in Prime Agent?
You must provide three components: a SKILL.md file containing the agent prompt and front-matter, a pyproject.toml defining the package metadata and dependencies, and a Python module at src/<import_name>/__init__.py implementing the skill logic. The import_name is derived from the skill name with all hyphens converted to underscores, as specified in packages/coding-agent/skills/skill-creator/references/python-skills.md.
How does Prime Agent handle dependencies for Python-backed skills?
Dependencies listed in pyproject.toml are automatically installed into the kernel virtual environment (default location: ~/.prime/agent/kernel-venv) when the skill is first loaded. The system uses editable installs to ensure the skill code remains updatable without reinstallation.
Can Python-backed skills be invoked from shell cells in Prime Agent?
Yes, when the pyproject.toml includes a [project.scripts] section mapping a command name to rlm.skill:cli, the skill becomes available as a shell command. You can invoke it using !<command_name> syntax from notebook cells, in addition to the standard Python await calls.
What happens if a Python-backed skill fails to import correctly?
If the Python import fails during skill loading, Prime Agent binds the skill name to a placeholder object that raises a RuntimeError when called. This design isolates the failure, allowing the IPython kernel to remain stable and other skills to function normally, unlike markdown skills which are simply skipped with a warning if their documentation is invalid.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →