Skip to main content

Agent Skills

Skills are reusable instruction sets that extend your Agent’s capabilities. Load skills for code review, data analysis, writing, and more - without modifying the Agent’s core instructions.

Agent with Skills

import { Agent, createSkillManager } from 'praisonai';

const skillManager = createSkillManager({
  paths: ['./skills']
});

// Discover available skills
await skillManager.discover();

// Create Agent with skills
const agent = new Agent({
  name: 'Skilled Agent',
  instructions: 'You are a helpful assistant.',
  skills: skillManager.list(['code-review', 'security-audit'])
});

// Agent now has code review and security audit capabilities
const response = await agent.chat('Review this code for issues: function add(a,b) { return a+b }');

Creating Skills for Agents

Skills are defined in SKILL.md files:
---
name: code-review
description: Review code for best practices, bugs, and security issues
license: MIT
compatibility: TypeScript, JavaScript, Python
allowed-tools: Read Grep
metadata:
  author: your-team
  version: "1.0"
---

# Code Review Skill

When reviewing code, follow these steps:

1. **Security Check**: Look for SQL injection, XSS, and auth issues
2. **Error Handling**: Verify try/catch blocks and error messages
3. **Type Safety**: Check for proper typing and null checks
4. **Performance**: Identify N+1 queries, memory leaks
5. **Best Practices**: Follow language conventions

Always provide specific line numbers and actionable suggestions.

Agent with Multiple Skills

import { Agent, createSkillManager } from 'praisonai';

const skillManager = createSkillManager({
  paths: ['./skills'],
  includeProject: true
});

await skillManager.discover();

// Agent with multiple specialized skills
const devAgent = new Agent({
  name: 'Developer Assistant',
  instructions: 'You help developers with code tasks.',
  skills: skillManager.list(['code-review', 'refactoring', 'testing', 'documentation'])
});

// Agent applies relevant skills based on the task
await devAgent.chat('Write unit tests for this function');  // Uses testing skill
await devAgent.chat('Refactor this class for better readability');  // Uses refactoring skill

Dynamic Skill Loading

Load skills based on context:
import { Agent, createSkillManager } from 'praisonai';

const skillManager = createSkillManager({ paths: ['./skills'] });
await skillManager.discover();

async function createContextualAgent(taskType: string) {
  // Select skills based on task
  const skillNames = {
    'code': ['code-review', 'debugging', 'testing'],
    'writing': ['grammar', 'style-guide', 'seo'],
    'data': ['data-analysis', 'visualization', 'statistics']
  }[taskType] || [];
  
  return new Agent({
    name: `${taskType} Agent`,
    instructions: `You specialize in ${taskType} tasks.`,
    skills: skillManager.list(skillNames)
  });
}

const codeAgent = await createContextualAgent('code');
const writingAgent = await createContextualAgent('writing');

Multi-Agent with Specialized Skills

import { Agent, PraisonAIAgents, createSkillManager } from 'praisonai';

const skillManager = createSkillManager({ paths: ['./skills'] });
await skillManager.discover();

// Each Agent has different skills
const securityAgent = new Agent({
  name: 'Security Expert',
  instructions: 'You focus on security analysis.',
  skills: skillManager.list(['security-audit', 'vulnerability-scan', 'penetration-testing'])
});

const performanceAgent = new Agent({
  name: 'Performance Expert',
  instructions: 'You optimize for performance.',
  skills: skillManager.list(['profiling', 'optimization', 'caching-strategies'])
});

const architectAgent = new Agent({
  name: 'Architect',
  instructions: 'You design system architecture.',
  skills: skillManager.list(['system-design', 'scalability', 'microservices'])
});

const agents = new PraisonAIAgents({
  agents: [securityAgent, performanceAgent, architectAgent],
  tasks: [
    { agent: securityAgent, description: 'Audit security of: {code}' },
    { agent: performanceAgent, description: 'Analyze performance issues' },
    { agent: architectAgent, description: 'Recommend architectural improvements' }
  ]
});

await agents.start({ code: 'application source code...' });

Agent Skill Injection

Inject skills into Agent prompts:
import { Agent, createSkillManager } from 'praisonai';

const skillManager = createSkillManager({ paths: ['./skills'] });
await skillManager.discover();

const agent = new Agent({
  name: 'Flexible Agent',
  instructions: 'You are a helpful assistant.'
});

// Inject skills dynamically per request
async function chatWithSkills(message: string, skillNames: string[]) {
  const skillPrompt = skillManager.generatePrompt(skillNames);
  
  return await agent.chat(`
${skillPrompt}

User Request: ${message}
  `);
}

// Different skills for different requests
await chatWithSkills('Review this code', ['code-review']);
await chatWithSkills('Write documentation', ['documentation', 'technical-writing']);

Skill Discovery Paths

Skills are discovered from multiple locations:
LocationPathPriority
Project./.praison/skills/Highest
Project./.claude/skills/High
User~/.praison/skills/Medium
System/etc/praison/skills/Lowest
const skillManager = createSkillManager({
  includeProject: true,   // .praison/skills/, .claude/skills/
  includeUser: true,      // ~/.praison/skills/
  includeSystem: false,   // /etc/praison/skills/
  paths: ['./custom-skills']  // Additional paths
});

Skill Validation

Validate skills before using with Agents:
const skillManager = createSkillManager({ paths: ['./skills'] });

const skill = await skillManager.loadSkill('./my-skill/SKILL.md');
const validation = skillManager.validate(skill);

if (!validation.valid) {
  console.log('Skill errors:', validation.errors);
} else {
  // Safe to use with Agent
  const agent = new Agent({
    name: 'Agent',
    skills: [skill]
  });
}
  • Tools - Give Agents executable capabilities
  • Workflows - Orchestrate skilled Agents
  • Multi-Agent - Teams of specialized Agents