templates/skills/modules/serena/SKILL.md
Use MCP Serena for AI-powered development assistance, code analysis, and intelligent automation.
npx skillsauth add hivellm/rulebook SerenaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CRITICAL: Use MCP Serena for AI-powered development assistance, code analysis, and intelligent automation.
// Analyze code quality
serena.analyze({
file: 'src/auth/login.ts',
checks: ['security', 'performance', 'best-practices']
})
// Get refactoring suggestions
serena.suggest({
file: 'src/legacy-code.js',
type: 'refactor',
target: 'modern'
})
// Detect code smells
serena.detectSmells({
directory: 'src/',
severity: 'high'
})
// Generate tests
serena.generateTests({
sourceFile: 'src/utils/validator.ts',
framework: 'vitest',
coverage: 'comprehensive'
})
// Generate documentation
serena.generateDocs({
files: ['src/**/*.ts'],
format: 'markdown',
includeExamples: true
})
// Generate types
serena.generateTypes({
from: 'api-schema.json',
to: 'src/types/api.ts',
style: 'strict'
})
// Extract function
serena.refactor({
action: 'extract-function',
file: 'src/complex-logic.ts',
selection: { start: 45, end: 78 },
newFunctionName: 'processUserData'
})
// Rename symbol
serena.refactor({
action: 'rename',
symbol: 'oldFunctionName',
newName: 'newFunctionName',
scope: 'project'
})
// Convert to async
serena.refactor({
action: 'convert-to-async',
file: 'src/sync-operations.ts'
})
// Get code review
serena.review({
files: ['src/new-feature/**/*.ts'],
focus: ['security', 'performance', 'maintainability'],
severity: 'warning-and-above'
})
// Check best practices
serena.checkBestPractices({
language: 'typescript',
framework: 'react',
files: 'src/components/**/*.tsx'
})
// Analyze changed files before commit
const changedFiles = execSync('git diff --cached --name-only').toString().split('\n')
for (const file of changedFiles) {
const analysis = await serena.analyze({
file,
checks: ['security', 'performance', 'best-practices']
})
if (analysis.issues.filter(i => i.severity === 'high').length > 0) {
console.error(`❌ High severity issues found in ${file}`)
process.exit(1)
}
}
// Generate tests for new features
const newFiles = findFilesWithoutTests('src/features/new-feature')
for (const file of newFiles) {
const tests = await serena.generateTests({
sourceFile: file,
framework: 'vitest',
coverage: 'comprehensive'
})
const testFile = file.replace('.ts', '.test.ts')
fs.writeFileSync(testFile, tests.code)
console.log(`✅ Generated tests for ${file}`)
}
// Generate project health report
const files = glob.sync('src/**/*.ts')
const report = {
totalFiles: files.length,
issues: [],
codeSmells: [],
coverage: 0
}
for (const file of files) {
const analysis = await serena.analyze({ file })
report.issues.push(...analysis.issues)
const smells = await serena.detectSmells({ file })
report.codeSmells.push(...smells)
}
// Post to dashboard
await grafana.dashboards.updateDashboard({
panels: [
{ title: 'Code Quality', value: calculateQualityScore(report) },
{ title: 'Issues', value: report.issues.length },
{ title: 'Code Smells', value: report.codeSmells.length }
]
})
// Identify and fix code smells automatically
const smells = await serena.detectSmells({
directory: 'src/',
severity: 'medium-and-above'
})
for (const smell of smells) {
if (smell.autoFixable) {
const result = await serena.refactor({
action: smell.suggestedAction,
file: smell.file,
selection: smell.location
})
if (result.success) {
console.log(`✅ Fixed: ${smell.description}`)
}
}
}
// Keep documentation in sync with code
const apiFiles = glob.sync('src/api/**/*.ts')
for (const file of apiFiles) {
const docs = await serena.generateDocs({
files: [file],
format: 'markdown',
includeExamples: true
})
const docFile = `docs/api/${path.basename(file, '.ts')}.md`
fs.writeFileSync(docFile, docs)
}
// Update CHANGELOG with AI summary
const changes = execSync('git log --oneline --since="1 week ago"').toString()
const summary = await serena.summarize({
text: changes,
format: 'changelog',
categorize: true
})
updateChangelog(summary)
// Migrate from old to new API
await serena.migrate({
from: 'old-api-v1',
to: 'new-api-v2',
files: 'src/**/*.ts',
strategy: 'safe', // safe, aggressive, manual
createBackup: true
})
// Update imports
await serena.refactor({
action: 'update-imports',
from: '@old-package',
to: '@new-package',
scope: 'project'
})
✅ DO:
❌ DON'T:
{
"mcpServers": {
"serena": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-serena"],
"env": {
"SERENA_API_KEY": "your-api-key",
"SERENA_MODEL": "gpt-4",
"SERENA_TEMPERATURE": "0.2"
}
}
}
}
Configuration Options:
SERENA_MODEL: AI model to use (gpt-4, claude-3, etc.)SERENA_TEMPERATURE: Creativity level (0.0-1.0, lower = more deterministic)SERENA_MAX_TOKENS: Maximum response lengthSERENA_TIMEOUT: Request timeout in secondsEnhance automation workflow with AI assistance:
// Step 1: AI-powered code review before quality checks
const review = await serena.review({
files: changedFiles,
focus: ['security', 'performance']
})
if (review.criticalIssues.length > 0) {
console.error('Critical issues found. Fix before proceeding.')
process.exit(1)
}
// Step 2: Generate missing tests
const filesWithoutTests = findFilesWithoutTests()
for (const file of filesWithoutTests) {
await serena.generateTests({ sourceFile: file })
}
// Step 3: Normal AGENT_AUTOMATION workflow
// (lint, test, coverage, etc.)
// Step 4: AI-powered commit message
const commitMessage = await serena.generateCommitMessage({
diff: execSync('git diff --cached').toString(),
style: 'conventional'
})
git commit -m "${commitMessage}"
# .github/workflows/serena-review.yml
name: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: AI Code Review
run: |
npx serena review \
--files="$(git diff --name-only origin/main)" \
--severity=warning \
--format=github-comment
env:
SERENA_API_KEY: ${{ secrets.SERENA_API_KEY }}
<!-- SERENA:END -->research
Author a rulebook task spec interactively — research, draft, ask the user clarifying questions, confirm, then create the tasks in rulebook ready for /rulebook-driver. Use when the user wants to plan/spec a feature before implementing.
development
Behavioral guidelines to reduce common LLM coding mistakes — overcomplication, sloppy refactors, hidden assumptions, weak goals. Use when writing, reviewing, or refactoring code. Auto-applies; invoke explicitly via /karpathy-guidelines or 'follow karpathy discipline'.
data-ai
Autonomous AI agent loop for iterative task implementation (@hivehub/rulebook ralph)
data-ai
Use SQL Server for enterprise relational data storage with advanced features, high availability, and Windows integration.