Learn a Skill from Sources
Point your agent at a repo, docs, PDFs, configs, or this chat — and it authors one grounded, reusable SKILL.md in a single command.
Learn-skill turns real source material — code, docs, PDFs, configs, or this chat — into one grounded, reusable SKILL.md in a single command.
from praisonaiagents import Agent
agent = Agent(name="SkillAuthor", instructions="Distil sources into reusable skills")
agent.learn_skill("Read ./my-repo and author a deploy-flow skill")The user points at repos or docs; the agent authors one grounded SKILL.md they can reuse later.
graph LR
subgraph "Learn a Skill from Sources"
SRC[📂 Sources<br/>repo / docs / PDFs / chat] --> A[🤖 Agent]
A --> G[🔍 Gather]
G --> D[🧠 Distil]
D --> S[✅ SKILL.md]
end
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
classDef process fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef result fill:#10B981,stroke:#7C90A0,color:#fff
class SRC input
class A agent
class G,D process
class S resultQuick Start
- Learn from a repo
python from praisonaiagents import Agent agent = Agent() agent.learn_skill( "Read ./my-repo and make a 'deploy-flow' skill" ) - Learn from multiple sources
python from praisonaiagents import Agent agent = Agent() agent.learn_skill( "Read ./my-repo and the docs in ./docs/*.pdf and make a 'deploy-flow' skill" ) - Learn from the current chat
python from praisonaiagents import Agent agent = Agent() agent.start("Walk me through deploying this service: …") agent.learn_skill("Save what we just figured out as a 'deploy-flow' skill")
How It Works
sequenceDiagram
participant User
participant Agent
participant Tools as File / PDF / Fetch
participant Skills as skill_manage
User->>Agent: agent.learn_skill("read ./repo, make 'deploy-flow' skill")
Agent->>Tools: gather only the named sources
Tools-->>Agent: source content (verbatim)
Agent->>Agent: distil SKILL.md (verbatim flags/paths only, ~100-200 lines)
Agent->>Skills: skill_manage(action="create", name="deploy-flow", content=…)
Skills-->>Agent: status: pending (approval gate) or live
Agent-->>User: "✅ Authored 'deploy-flow' skill — <summary>"The agent follows three rules when authoring a skill:
| Rule | What it means |
|---|---|
| Verbatim only | Only flags, paths, commands, env vars, and API names that appear verbatim in the gathered sources end up in the skill. Never invented. |
| Tight body | SKILL.md is kept to ~100–200 lines. Long material moves to supporting files referenced by relative path. |
| Named sources only | The agent reads only the sources you name. It does not browse unrelated material. |
| YAML frontmatter | Every generated skill has at least name + description. |
Three Surfaces
Python SDK
from praisonaiagents import Agent
agent = Agent()
agent.learn_skill("Read ./my-repo and make a 'deploy-flow' skill")CLI
praisonai skills learn "the API in ./openapi.yaml as a 'stripe-billing' skill"Bot Chat
/learn deploy steps from this repo and the runbook PDFAsync
from praisonaiagents import Agent
agent = Agent()
result = await agent.alearn_skill(
"Read ./my-repo and make a 'deploy-flow' skill"
)Approval Gate
Common Patterns
From a single repo
from praisonaiagents import Agent
agent = Agent()
agent.learn_skill("Read ./my-repo and make a 'deploy-flow' skill")Multi-source (repo + PDFs + URL)
The agent picks the right tool per source — file read, PDF read, or fetch — automatically.
from praisonaiagents import Agent
agent = Agent()
agent.learn_skill(
"Read ./my-repo, the runbook at ./docs/runbook.pdf, "
"and https://docs.example.com/api — make a 'deploy-flow' skill"
)From the current chat
Phrases like "what we just figured out" or "this conversation" route the agent to use the chat as the source.
from praisonaiagents import Agent
agent = Agent()
agent.start("Walk me through deploying this service to AWS…")
agent.learn_skill("Save what we just figured out as a 'deploy-flow' skill")CLI with model override
praisonai skills learn "the API in ./openapi.yaml as a 'stripe-billing' skill" --llm gpt-4oWhat the Grounded Prompt Enforces
The internal build_learn_prompt function generates a directive with strict house-style rules:
| Rule | Detail |
|---|---|
| Gather only named sources | Reads local files/directories, PDFs, fetched URLs, or the current chat — only sources the user named |
| Verbatim accuracy | Uses only flags, paths, commands, env vars, and API names that appear verbatim in the gathered sources — never invented |
Tight SKILL.md | Keeps the file ~100–200 lines; moves long reference material (large code, full API tables) to supporting files referenced by relative path |
| YAML frontmatter | Must include at least name and description |
| Single write | Authors one skill via skill_manage(action="create", name="kebab-case-name", content="...") |
| Supporting files | Long material goes to separate files via skill_manage(action="write_file", ...) |
Bot Usage
All PraisonAI bot adapters (Telegram, Slack, Discord) register /learn via the shared CommandRegistry.
/learn <sources and skill to make>Example:
/learn deploy steps from this repo and the runbook PDFUsage hint (when called without arguments):
ℹ️ Usage: /learn <sources and skill to make>
Example: /learn deploy steps from this repo and the runbook PDFAdmin-Only Default
/learn reads host file system sources and authors skills that alter future agent behaviour. It belongs to PRIVILEGED_COMMANDS in CommandAccessPolicy — it is admin-only by default whenever a policy is configured (admin_users or user_allowed_commands set).
Without any policy configured, /learn is available to all users (backward-compatible behaviour).
See Bot Command Access Control to configure admin_users and grant selective access.
Best Practices
Name sources explicitly
Saying “read ./my-repo and ./docs/*.pdf” beats “learn about deploys” because the agent only reads what you name. Explicit paths give better, more grounded skills.
Pick a kebab-case skill name in the request
Include a quoted name like "… make a 'deploy-flow' skill". If you omit it, the agent derives one from the content — which may be less predictable.
Prefer learn_skill over learn in new code
learn / alearn are kept as backward-compat aliases. The canonical names are learn_skill / alearn_skill to avoid confusion with the memory learn= constructor param on Agent.
Don't pre-wire skill_manage yourself
learn_skill automatically adds skill_manage, read_skill_file, and list_skill_scripts to agent.tools if they are missing. The call is idempotent — running it multiple times does not double-register tools.
Backward-compat Aliases
learn and alearn are aliases for learn_skill and alearn_skill:
agent.learn("Read ./my-repo and make a 'deploy-flow' skill")
await agent.alearn("Read ./my-repo and make a 'deploy-flow' skill")Prefer learn_skill / alearn_skill in new code.
Related
The approval gate the authored skill flows through
Agent SkillsInvoking and discovering skills
Self-Improving AgentsAuto-curate skills from conversation (different mechanism)
Prompt OptimizerSibling self-improvement method that optimises the agent’s instructions
Bot Chat Commands/learn slash command in Telegram, Discord, and Slack