Learn Skill

Author a grounded, reusable SKILL.md from any source — codebase, API docs, PDFs, configs, or the current chat — in a single command

python
from praisonaiagents import Agent

agent = Agent(name="Skill Author", instructions="Distil reusable skills from source material.")
agent.learn("Create a deploy-flow skill from this repo and runbook.")

Point an agent at real source material and get one grounded SKILL.md back — ready to reuse immediately.

The user points the agent at repos or docs; it distils a reusable SKILL.md the team can invoke on later runs.

Diagram

Learn Skill Flow

📝 Request

🔍 Gather sources

✍️ Distil SKILL.md

💾 Write via skill_manage

✅ Reusable skill

Quick Start

  1. Agent: learn from sources
    python
    from praisonaiagents import Agent
    
    agent = Agent(name="Skill Author", instructions="You learn and write skills.")
    agent.learn("Read ./my-repo and the docs in ./docs/*.pdf and make a 'deploy-flow' skill")
  2. Bot: /learn slash command

    Type /learn in any PraisonAI bot chat (Telegram, Slack, Discord):

    /learn deploy steps from this repo and the runbook PDF
  3. Async and alias variants
    python
    # Async variant (event-loop friendly)
    await agent.alearn("Read ./my-repo and make a 'ci-deploy' skill")
    
    # Backward-compatible aliases
    agent.learn("...")          # alias for learn_skill()
    await agent.alearn("...")   # alias for alearn_skill()

How It Works

Diagram
SKILL.mdskill_manage + readersbuild_learn_promptAgentUserSKILL.mdskill_manage + readersbuild_learn_promptAgentUseragent.learn(“Read ./my-repo…”)build_learn_prompt(request)grounded authoring directivegather named sources (files, PDFs, URLs)source contentskill_manage(action=”create”, …)SKILL.md written to diskskill name + summary“Created ‘deploy-flow’ skill covering…”

Agent.learn_skill() calls build_learn_prompt(request) to build a curated directive, ensures skill_manage (and lightweight file/PDF readers) are available via _ensure_skill_management_tools(), then invokes start() for a single turn.


What the Grounded Prompt Enforces

The internal build_learn_prompt function generates a directive with strict house-style rules:

RuleDetail
Gather only named sourcesReads local files/directories, PDFs, fetched URLs, or the current chat — only sources the user named
Verbatim accuracyUses only flags, paths, commands, env vars, and API names that appear verbatim in the gathered sources — never invented
Tight SKILL.mdKeeps the file ~100–200 lines; moves long reference material (large code, full API tables) to supporting files referenced by relative path
YAML frontmatterMust include at least name and description
Single writeAuthors one skill via skill_manage(action="create", name="kebab-case-name", content="...")
Supporting filesLong material goes to separate files via skill_manage(action="write_file", ...)

Configuration

ParameterTypeDefaultDescription
requeststrrequiredDescription of sources to learn from and the skill to produce
**kwargsAny—Forwarded to start() / astart()

_ensure_skill_management_tools() adds skill_manage, read_skill_file, and list_skill_scripts to self.tools if they are not already present. This is idempotent — safe to call multiple times.


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 PDF

Usage hint (when called without arguments):

ℹ️ Usage: /learn <sources and skill to make>
Example: /learn deploy steps from this repo and the runbook PDF

Admin-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.


Common Patterns

Learn from a Codebase

python
from praisonaiagents import Agent

agent = Agent(name="Skill Author", instructions="You learn and write skills.")
agent.learn("Read ./my-repo and make a 'dev-setup' skill covering the full local dev workflow")

Learn from PDFs + Code

python
agent.learn(
    "Read ./src and the PDF manuals in ./docs/manuals/*.pdf "
    "and make a 'data-ingestion' skill"
)

Learn from the Current Chat

python
agent.learn("Distil what we just did into a 'feature-branch' skill")

Async in an Event Loop

python
import asyncio
from praisonaiagents import Agent

async def main():
    agent = Agent(name="Skill Author", instructions="You learn and write skills.")
    await agent.alearn_skill("Read ./docs and make an 'api-reference' skill")

asyncio.run(main())

Best Practices

Name skills explicitly

Include the target skill name in the request (e.g., "make a 'deploy-flow' skill") so the agent uses that exact kebab-case name rather than deriving one. Consistent names make it easier to invoke and update skills later.

Scope the sources tightly

List only the directories, files, or PDFs the skill should cover. Broad requests like "read everything" risk the agent browsing unrelated material or timing out. Narrow sources produce more accurate skills.

Use alearn_skill in async code

In async contexts (FastAPI endpoints, bot handlers), call await agent.alearn_skill(...) instead of agent.learn_skill(...) to avoid blocking the event loop during potentially long source-gathering turns.

Check skill_manage availability

learn_skill auto-adds skill_manage if missing, but if you’ve set tools=[] explicitly on the agent, ensure the agent has read access to the source directories too (the skill_manage file readers need filesystem access).


Related