API Reference
Core package API for programmatic skill management
API Reference
The @skillkit/core package provides the foundational business logic with zero internal dependencies.
Installation
npm install @skillkit/coreModule Exports
| Entry Point | Purpose |
|---|---|
@skillkit/core | Main exports |
@skillkit/core/types | Type definitions |
@skillkit/core/discovery | Skill discovery |
@skillkit/core/parser | SKILL.md parsing |
@skillkit/core/translator | Format translation |
@skillkit/core/context | Project context |
@skillkit/core/recommend | Recommendation engine |
Skill Discovery
import { findAllSkills, findSkill } from '@skillkit/core/discovery'
// Find all skills in directory
const skills = await findAllSkills('./my-project')
// Find specific skill
const skill = await findSkill('react-patterns')Quality Evaluation
import { evaluateSkillContent, getQualityGrade } from '@skillkit/core'
const score = evaluateSkillContent(skillContent)
// { total: 85, structure: 22, clarity: 25, specificity: 28, advanced: 10 }
const grade = getQualityGrade(score.total)
// 'B'Dimensions (weights out of 100):
- Structure (25): Frontmatter, sections
- Clarity (30): Descriptions, examples
- Specificity (30): Actionable steps
- Advanced (15): Tests, versioning
Translation
import { translateSkill } from '@skillkit/core/translator'
const result = await translateSkill(skillContent, 'cursor')
// { content: '...', filename: 'skill.mdc' }Memory System
import { MemoryCompressor, LearningStore } from '@skillkit/core'
// Compress observations
const compressor = new MemoryCompressor()
const learning = await compressor.compress(observations)
// Store and search
const store = new LearningStore()
await store.add(learning)
const results = await store.search('authentication')Recommendation Engine
import { RecommendationEngine, analyzeProject } from '@skillkit/core/recommend'
const engine = new RecommendationEngine()
const profile = await analyzeProject('./my-project')
const recommendations = engine.recommend(profile)
// Recommendations with scores and reasons
recommendations.forEach(rec => {
console.log(`${rec.score}% - ${rec.skill.name}`)
console.log(`Reasons: ${rec.reasons.join(', ')}`)
})Primer (Auto-Generate Instructions)
import { promises as fs } from 'node:fs'
import { analyzeProject, generateInstructions } from '@skillkit/core'
// Analyze project
const analysis = await analyzeProject('./my-project')
console.log(analysis.techStack)
// { framework: 'Next.js', language: 'TypeScript', styling: 'Tailwind' }
// Generate instructions for specific agents
const instructions = await generateInstructions(analysis, {
agents: ['claude', 'cursor', 'windsurf'],
includeExamples: true,
tone: 'detailed',
})
// Write to files
for (const [agent, content] of Object.entries(instructions)) {
await fs.writeFile(`.${agent}/instructions.md`, content)
}Mesh Network
import { MeshHost, PeerIdentity } from '@skillkit/mesh'
// Generate identity
const identity = await PeerIdentity.generate()
// Create mesh host
const host = new MeshHost({
hostId: 'my-workstation',
identity,
security: { mode: 'secure' },
})
await host.start()
// Send message to peer
await host.send('peer-fingerprint', {
type: 'skill-sync',
payload: { skills: ['react-patterns'] },
})
// Listen for messages
host.on('message', (msg) => {
console.log('Received:', msg.type, 'from', msg.from)
})Inter-Agent Messaging
import { MessagingClient } from '@skillkit/messaging'
// Create messaging client (host is a MeshHost instance from the example above)
const messaging = new MessagingClient({
meshHost: host, // See MeshHost setup in "Mesh Network" section above
storagePath: '~/.skillkit/messages',
})
await messaging.init()
// Send a message
await messaging.send({
to: 'claude@laptop',
subject: 'Code review completed',
body: 'I reviewed the auth module...',
priority: 'normal',
})
// Listen for new messages
messaging.on('message', (msg) => {
console.log('New message from:', msg.from)
console.log('Subject:', msg.subject)
})
// Get inbox
const inbox = await messaging.getInbox({ unread: true })Workflow Orchestration
import { WorkflowEngine, WorkflowStep } from '@skillkit/core'
// Define workflow
const workflow = {
name: 'feature-development',
steps: [
{ skill: 'tdd-workflow', action: 'write-tests' },
{ skill: 'code-implementation', action: 'implement' },
{ skill: 'code-review', action: 'review' },
{ skill: 'documentation', action: 'update-docs' },
],
}
// Execute workflow
const engine = new WorkflowEngine()
const result = await engine.run(workflow)
console.log('Workflow completed:', result.status)
console.log('Steps executed:', result.steps.length)Skill Testing
import { SkillTestRunner, SkillTest } from '@skillkit/core'
// Define test
const test: SkillTest = {
name: 'pdf-processing',
setup: async () => {
// Setup test environment
},
assertions: [
{
type: 'file_exists',
path: './output.pdf',
},
{
type: 'content_includes',
text: 'Expected content',
},
],
}
// Run test
const runner = new SkillTestRunner()
const result = await runner.run(test)
console.log('Test passed:', result.passed)
console.log('Assertions:', result.assertions)Types
interface Skill {
name: string
description: string
path: string
content: string
metadata: SkillMetadata
enabled: boolean
agent: string
}
interface SkillMetadata {
version?: string
author?: string
tags?: string[]
dependencies?: string[]
quality?: QualityScore
}
interface QualityScore {
total: number // 0-100
structure: number // 0-25
clarity: number // 0-30
specificity: number // 0-30
advanced: number // 0-15
}
interface Recommendation {
skill: Skill
score: number
reasons: string[]
}
interface ProjectAnalysis {
techStack: {
framework?: string
language: string
styling?: string
testing?: string
packageManager: string
}
patterns: {
architecture: string
codeStyle: Record<string, any>
directory: string
}
dependencies: Record<string, string>
}
interface MeshMessage {
from: string
to: string
type: string
payload: any
timestamp: number
signature?: string
}
interface WorkflowResult {
status: 'success' | 'failure'
steps: WorkflowStepResult[]
duration: number
}Package Exports
@skillkit/core
export {
// Discovery
findAllSkills,
findSkill,
// Quality
evaluateSkillContent,
getQualityGrade,
// Translation
translateSkill,
// Memory
MemoryCompressor,
LearningStore,
// Recommendations
RecommendationEngine,
analyzeProject,
// Primer
generateInstructions,
// Workflows
WorkflowEngine,
// Testing
SkillTestRunner,
}@skillkit/mesh
export {
MeshHost,
PeerIdentity,
PeerRegistry,
SecureTransport,
}@skillkit/messaging
export {
MessagingClient,
MessageBuilder,
MessageRouter,
}@skillkit/memory
export {
MemoryStore,
TierManager,
EmbeddingEncoder,
}Full Example: Custom Build Pipeline
import { promises as fs } from 'node:fs'
import {
analyzeProject,
generateInstructions,
RecommendationEngine,
translateSkill,
} from '@skillkit/core'
async function setupProject() {
// 1. Analyze project
const analysis = await analyzeProject('./my-project')
// 2. Generate base instructions
const instructions = await generateInstructions(analysis, {
agents: ['claude', 'cursor', 'windsurf'],
})
// 3. Get recommendations
const engine = new RecommendationEngine()
const recommendations = engine.recommend(analysis)
// 4. Install top recommendations
const topSkills = recommendations.slice(0, 5)
for (const rec of topSkills) {
console.log(`Installing ${rec.skill.name} (${rec.score}% match)`)
}
// 5. Translate skills to all agents
for (const agent of ['claude', 'cursor', 'windsurf']) {
const translated = await translateSkill(
topSkills[0].skill.content,
agent
)
await fs.writeFile(`.${agent}/skills/${translated.filename}`, translated.content)
}
console.log('✅ Project setup complete!')
}
setupProject()Next Steps
- Commands Reference - CLI commands
- Memory System - Persistent learning
- Mesh Network - Multi-machine setup
- Workflows - Automation
- Testing - Skill validation