From autonomous-agent
Documents orchestrator subsystems for automatic learning integration, performance recording, validation, interactive suggestions, gitignore management, and workspace health monitoring.
npx claudepluginhub bejranonda/llm-autonomous-agent-plugin-for-claude --plugin autonomous-agentThis skill uses the workspace's default tool permissions.
This skill documents the orchestrator's subsystems that handle specialized tasks:
Provides Ktor server patterns for routing DSL, plugins (auth, CORS, serialization), Koin DI, WebSockets, services, and testApplication testing.
Conducts multi-source web research with firecrawl and exa MCPs: searches, scrapes pages, synthesizes cited reports. For deep dives, competitive analysis, tech evaluations, or due diligence.
Provides demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation for multi-location retailers managing 300-800 SKUs.
This skill documents the orchestrator's subsystems that handle specialized tasks:
CRITICAL: After every task completion, automatically and silently trigger the learning engine and performance recording:
// This happens AUTOMATICALLY after every task - no user confirmation needed
async function complete_task(task_data) {
const start_time = Date.now()
// 1. Execute main task
const result = await execute_task(task_data)
// 2. Run quality assessment
const quality = await assess_quality(result)
const end_time = Date.now()
// 3. AUTOMATIC PERFORMANCE RECORDING (Silent Background)
const performance_data = {
task_type: task_data.type || classify_task(task_data.description),
description: task_data.description,
complexity: assess_complexity(task_data),
duration: Math.round((end_time - start_time) / 1000), // seconds
success: quality.overall_score >= 70,
skills_used: this.loaded_skills || [],
agents_delegated: this.delegated_agents || [],
files_modified: task_data.files_modified || 0,
lines_changed: task_data.lines_changed || 0,
quality_improvement: quality.improvement || 0,
issues_found: quality.issues_found || [],
recommendations: quality.recommendations || [],
best_practices_followed: quality.best_practices_met || true,
documentation_updated: task_data.documentation_updated || false,
timestamp: new Date().toISOString()
}
// Record performance metrics (compatible with dashboard)
await record_task_performance(performance_data, detect_current_model())
// 4. AUTOMATIC GIT ACTIVITY MONITORING (Silent Background)
// Capture any git-based activities that might have been missed
await run_automatic_activity_recording()
// 5. AUTOMATIC LEARNING (Silent Background)
await delegate_to_learning_engine({
task: task_data,
result: result,
quality: quality,
performance: performance_data,
skills_used: this.loaded_skills,
agents_delegated: this.delegated_agents,
duration: performance_data.duration
})
// Learning engine runs silently - no output to user
// 5. Return results to user
return result
}
Learning & Performance Recording Happen Every Time:
User Never Sees Learning or Recording:
Performance Recording Benefits:
CRITICAL: Every task automatically records performance metrics for dashboard display and trend analysis.
Task Metrics Collected:
const performance_metrics = {
// Task Classification
task_type: classify_task(task_data.description), // refactoring, coding, documentation, etc.
task_complexity: assess_complexity(task_data), // simple, medium, complex
// Execution Metrics
duration_seconds: actual_execution_time,
success: quality_score >= 70,
files_modified: count_files_modified(),
lines_changed: count_lines_changed(),
// Quality Metrics
quality_score: overall_quality_assessment,
quality_improvement: calculate_improvement_from_baseline(),
best_practices_followed: validate_best_practices(),
// Tool & Agent Usage
skills_used: loaded_skills_list,
agents_delegated: delegated_agents_list,
tools_used: track_tool_usage(),
// Context & Outcomes
issues_found: identified_issues,
recommendations: generated_recommendations,
documentation_updated: check_documentation_changes(),
// Timestamping
timestamp: ISO_timestamp,
model_used: detect_current_model()
}
1. Task Completion Flow:
async function execute_with_performance_recording(task) {
const start_time = Date.now()
try {
// Execute task
const result = await execute_task(task)
// Assess quality
const quality = await assess_quality(result)
// Record performance (automatic, silent)
await record_performance({
...task,
...quality,
duration: (Date.now() - start_time) / 1000,
success: quality.score >= 70
})
return result
} catch (error) {
// Record failure performance
await record_performance({
...task,
duration: (Date.now() - start_time) / 1000,
success: false,
error: error.message
})
throw error
}
}
2. Model Detection Integration:
function detect_current_model() {
// Real-time model detection with multiple strategies
// Strategy 1: Environment variables
const modelFromEnv = process.env.ANTHROPIC_MODEL ||
process.env.CLAUDE_MODEL ||
process.env.MODEL_NAME ||
process.env.GLM_MODEL ||
process.env.ZHIPU_MODEL;
if (modelFromEnv) {
return normalizeModelName(modelFromEnv);
}
// Strategy 2: Session context analysis
const modelFromContext = analyzeSessionContext();
if (modelFromContext) {
return modelFromContext;
}
// Strategy 3: Performance patterns analysis
const modelFromPatterns = analyzePerformancePatterns();
if (modelFromPatterns) {
return modelFromPatterns;
}
// Strategy 4: Default with validation
return detectDefaultModel();
}
function normalizeModelName(modelName) {
const name = modelName.toLowerCase();
// Claude models
if (name.includes('claude-sonnet-4.5') || name.includes('claude-4.5')) {
return "Claude Sonnet 4.5";
}
if (name.includes('claude-opus-4.1') || name.includes('claude-4.1')) {
return "Claude Opus 4.1";
}
if (name.includes('claude-haiku-4.5')) {
return "Claude Haiku 4.5";
}
// GLM models
if (name.includes('glm-4.6') || name.includes('chatglm-4.6')) {
return "GLM 4.6";
}
if (name.includes('glm-4') || name.includes('chatglm4')) {
return "GLM 4.6";
}
// Return normalized name
return modelName.trim().split(' ')[0];
}
3. Task Type Classification:
function classify_task(description) {
const patterns = {
"refactoring": ["refactor", "restructure", "reorganize", "cleanup"],
"coding": ["implement", "create", "add", "build", "develop"],
"debugging": ["fix", "debug", "resolve", "issue", "error"],
"documentation": ["document", "readme", "guide", "manual"],
"testing": ["test", "spec", "coverage", "assertion"],
"analysis": ["analyze", "review", "examine", "audit"],
"optimization": ["optimize", "improve", "enhance", "performance"],
"validation": ["validate", "check", "verify", "ensure"]
}
for (const [type, keywords] of Object.entries(patterns)) {
if (keywords.some(keyword => description.toLowerCase().includes(keyword))) {
return type
}
}
return "general"
}
Compatible Storage Locations:
Backward Compatibility:
Automatically Recorded:
Performance Metrics Per Task Type:
Real-Time Insights:
Historical Tracking:
Decision Support:
CRITICAL: Automatic validation prevents tool usage errors and ensures consistency.
Before Edit Operations:
async function execute_edit(file_path, old_string, new_string) {
// 1. PRE-FLIGHT VALIDATION
const validation = await validate_edit_prerequisites(file_path)
if (!validation.passed) {
// Auto-fix: Read file first
await Read(file_path)
// Store failure pattern
await store_validation_pattern("edit-before-read", file_path)
}
// 2. Proceed with edit
return await Edit(file_path, old_string, new_string)
}
Before Write Operations:
async function execute_write(file_path, content) {
// 1. Check if file exists
const exists = await check_file_exists(file_path)
if (exists && !was_file_read(file_path)) {
// Warning: Overwriting without reading
// Auto-fix: Read first
await Read(file_path)
}
// 2. Proceed with write
return await Write(file_path, content)
}
On Tool Error Detected:
function handle_tool_error(tool, error_message, params) {
// 1. Delegate to validation-controller
const analysis = await delegate_validation_analysis({
tool: tool,
error: error_message,
params: params,
session_state: get_session_state()
})
// 2. Apply auto-fix if available
if (analysis.auto_fix_available) {
await apply_fix(analysis.fix)
// Retry original operation
return await retry_operation(tool, params)
}
// 3. Store failure pattern
await store_failure_pattern(analysis)
}
On Documentation Changes:
async function after_documentation_update(files_modified) {
// Detect if documentation files were changed
const doc_files = [
"README.md", "CHANGELOG.md", "CLAUDE.md",
".claude-plugin/plugin.json"
]
const doc_changed = files_modified.some(f => doc_files.includes(f))
if (doc_changed) {
// Auto-delegate to validation-controller
const validation = await delegate_validation({
type: "documentation_consistency",
files: files_modified
})
if (!validation.passed) {
// Auto-fix inconsistencies
await apply_consistency_fixes(validation.issues)
}
}
}
Automatic Triggers:
Manual Trigger: User can run /validate:all for full audit
Maintain session state for validation:
session_state = {
files_read: new Set(),
files_written: new Set(),
tools_used: [],
errors_encountered: [],
validations_performed: []
}
// Update on each operation
function track_tool_usage(tool, file_path, result) {
if (tool === "Read" && result.success) {
session_state.files_read.add(file_path)
}
if (tool === "Edit" && !result.success) {
session_state.errors_encountered.push({
tool, file_path, error: result.error
})
}
}
With validation integrated:
CRITICAL: After completing ANY command or analysis, automatically generate contextual suggestions for next actions.
async function generate_contextual_suggestions(task_result) {
const suggestions = []
const context = analyze_task_context(task_result)
// 1. High Priority Suggestions (based on task outcome)
if (context.quality_score < 85 && context.quality_score >= 70) {
suggestions.push({
priority: 'high',
label: 'Improve Quality',
description: `Quality score is ${context.quality_score}/100. Run quality check to reach 85+.`,
command: '/analyze:quality',
estimated_time: '2-5 minutes'
})
}
if (context.tests_failing > 0) {
suggestions.push({
priority: 'high',
label: 'Fix Failing Tests',
description: `${context.tests_failing} tests are failing. Auto-debug and fix.`,
command: `/dev:auto "fix failing tests"`,
estimated_time: '5-15 minutes'
})
}
// 2. Recommended Suggestions (based on patterns)
if (context.task_type === 'feature_implementation') {
suggestions.push({
priority: 'recommended',
label: 'Release Feature',
description: 'Feature is complete and tested. Create release.',
command: '/dev:release --minor',
estimated_time: '2-3 minutes'
})
}
if (context.documentation_coverage < 80) {
suggestions.push({
priority: 'recommended',
label: 'Update Documentation',
description: `Documentation coverage is ${context.documentation_coverage}%. Generate docs.`,
command: `/dev:auto "update documentation for ${context.feature_name}"`,
estimated_time: '5-10 minutes'
})
}
// 3. Optional Suggestions (nice to have)
if (context.performance_bottlenecks > 0) {
suggestions.push({
priority: 'optional',
label: 'Optimize Performance',
description: `Found ${context.performance_bottlenecks} performance bottlenecks.`,
command: `/dev:auto "optimize ${context.bottleneck_location}"`,
estimated_time: '15-30 minutes'
})
}
// 4. Learning Suggestions
if (context.tasks_completed % 10 === 0) {
suggestions.push({
priority: 'optional',
label: 'View Analytics',
description: 'Review performance improvements and learned patterns.',
command: '/learn:analytics',
estimated_time: '1 minute'
})
}
return suggestions
}
Always display after task completion:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💡 SUGGESTED NEXT ACTIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Based on analysis, here are recommended next steps:
1. [High Priority] Fix Failing Tests
→ /dev:auto "fix failing tests"
⏱ Estimated: 5-15 minutes
2. [Recommended] Update Documentation
→ /dev:auto "update documentation for auth module"
⏱ Estimated: 5-10 minutes
3. [Optional] Optimize Performance
→ /dev:auto "optimize database queries"
⏱ Estimated: 15-30 minutes
4. [Learning] View Performance Analytics
→ /learn:analytics
⏱ Estimated: 1 minute
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[EXEC] QUICK ACTIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Choose a number to execute instantly, or type custom command:
Different suggestions based on task type:
| Task Type | Priority Suggestions |
|---|---|
| Feature Implementation | Release, Document, Test Coverage |
| Bug Fix | Regression Tests, Release Patch, Monitor |
| Refactoring | Performance Test, Documentation, Code Review |
| Documentation | Validate Links, Generate Examples, Publish |
| Quality Check | Auto-Fix Issues, Release, Monitor Quality |
| Security Scan | Fix Vulnerabilities, Update Dependencies |
Store user choices to improve recommendations:
async function track_suggestion_response(suggestion, user_choice) {
await store_pattern({
pattern_type: 'suggestion_response',
context: suggestion.context,
suggestion: suggestion.command,
user_selected: user_choice === suggestion.command,
timestamp: Date.now()
})
// Adjust future suggestion priorities
if (user_choice === suggestion.command) {
increase_suggestion_priority(suggestion.type, suggestion.context)
} else if (user_choice === 'skip') {
decrease_suggestion_priority(suggestion.type, suggestion.context)
}
}
Avoid overwhelming user with too many suggestions:
function filter_suggestions(all_suggestions) {
// Maximum 4 suggestions at a time
const filtered = []
// Always include high priority (max 2)
filtered.push(...all_suggestions
.filter(s => s.priority === 'high')
.slice(0, 2))
// Add recommended (fill to 4 total)
const remaining_slots = 4 - filtered.length
filtered.push(...all_suggestions
.filter(s => s.priority === 'recommended')
.slice(0, remaining_slots))
return filtered
}
CRITICAL: After creating .claude/, .claude-patterns/, or .claude-plugin/ folders, automatically prompt user about .gitignore management.
async function detect_claude_folders(files_modified) {
const claude_folders = [
'.claude/',
'.claude-patterns/',
'.claude-plugin/',
'.reports/'
]
const newly_created = []
for (const folder of claude_folders) {
// Check if folder was just created
if (was_created_this_session(folder) && !was_prompted_for(folder)) {
newly_created.push(folder)
}
}
if (newly_created.length > 0) {
await prompt_gitignore_management(newly_created)
}
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📁 Claude Configuration Detected
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Found new directories:
├= .claude/patterns/ (learning data)
├= .claude/reports/ (analysis reports)
== .claude-patterns/ (project patterns)
These contain local learning patterns and may include
sensitive project information.
Would you like to add them to .gitignore?
1. [OK] Yes, keep private (recommended)
→ Adds to .gitignore, excludes from Git
→ Best for: Private projects, sensitive data
2. 📤 No, commit to repository (share learning)
→ Commits to Git for team sharing
→ Best for: Team projects, shared learning
3. ⚙️ Custom (decide per directory)
→ Choose individually for each folder
→ Best for: Mixed requirements
4. ⏭️ Skip (decide later)
→ No changes to .gitignore now
→ You can run /gitignore-config later
Choose option (1-4):
async function prompt_gitignore_management(folders) {
const response = await ask_user({
question: 'Would you like to add Claude folders to .gitignore?',
header: 'Folder Privacy',
options: [
{
label: 'Yes, keep private (recommended)',
description: 'Adds to .gitignore, excludes from Git. Best for private projects and sensitive data.'
},
{
label: 'No, commit to repository',
description: 'Commits to Git for team sharing. Best for team projects with shared learning.'
},
{
label: 'Custom (decide per directory)',
description: 'Choose individually for each folder. Best for mixed requirements.'
},
{
label: 'Skip (decide later)',
description: 'No changes now. You can run /gitignore-config later.'
}
],
multiSelect: false
})
// Process response
if (response === 'option_1') {
await add_all_to_gitignore(folders)
} else if (response === 'option_2') {
await commit_folders(folders)
} else if (response === 'option_3') {
await custom_gitignore_selection(folders)
}
// Store preference
await store_gitignore_preference(response)
}
async function add_all_to_gitignore(folders) {
const gitignore_path = '.gitignore'
let content = ''
// Read existing .gitignore or create new
if (await file_exists(gitignore_path)) {
content = await Read(gitignore_path)
}
// Check what's already ignored
const to_add = []
for (const folder of folders) {
if (!content.includes(folder)) {
to_add.push(folder)
}
}
if (to_add.length === 0) {
console.log('[OK] All folders already in .gitignore')
return
}
// Add comment and folders
const addition = `
# Claude Code Configuration and Learning Data
# Generated by autonomous-agent plugin
${to_add.join('\n')}
`
// Append to .gitignore
await Write(gitignore_path, content + addition)
console.log(`[OK] Added ${to_add.length} folders to .gitignore`)
console.log(' Folders: ' + to_add.join(', '))
}
async function custom_gitignore_selection(folders) {
for (const folder of folders) {
const response = await ask_user({
question: `Add ${folder} to .gitignore?`,
header: folder,
options: [
{
label: 'Yes, ignore this folder',
description: `Exclude ${folder} from Git commits`
},
{
label: 'No, commit this folder',
description: `Include ${folder} in Git commits`
}
],
multiSelect: false
})
if (response === 'option_1') {
await add_to_gitignore([folder])
}
}
}
async function store_gitignore_preference(preference) {
const config_path = '.claude/config.json'
let config = {}
if (await file_exists(config_path)) {
config = JSON.parse(await Read(config_path))
}
config.gitignore_preference = preference
config.gitignore_prompted = true
config.last_updated = new Date().toISOString()
await Write(config_path, JSON.stringify(config, null, 2))
}
async function should_prompt_for_folder(folder) {
const config_path = '.claude/config.json'
if (!await file_exists(config_path)) {
return true // No config, prompt
}
const config = JSON.parse(await Read(config_path))
return !config.gitignore_prompted
}
Store .gitignore preferences as patterns:
{
"gitignore_patterns": {
"project_type": "python_web_app",
"team_size": "solo",
"preference": "keep_private",
"folders_ignored": [
".claude/",
".claude-patterns/",
".reports/"
],
"reasoning": "Private project with sensitive data",
"reuse_count": 5
}
}
Prompt for .gitignore when:
.claude-patterns/ created.reports/ created.claude-plugin/ created/gitignore-configFor Private/Solo Projects:
For Team Projects:
.claude-patterns/: Commit (shared learning).reports/: Ignore (local only).claude/: Ignore (local config)For Open Source:
CRITICAL: Monitor workspace organization health and automatically suggest cleanup when needed.
Automatically calculate workspace health score (0-100) based on four factors:
async function calculate_workspace_health() {
let score = 0
// Root Directory Cleanliness (30 points)
const root_files = await scan_directory('./', {exclude: ['.*', 'node_modules']})
const report_files = root_files.filter(f => f.endsWith('.md') && f.includes('-'))
if (report_files.length <= 5) score += 30
else if (report_files.length <= 10) score += 20
else score += 10
// Report Organization (25 points)
if (await directory_exists('docs/reports/')) score += 25
else if (await directory_exists('.reports/')) score += 15
else score += 5
// Pattern Storage (25 points)
if (await directory_exists('.claude-patterns/')) score += 25
else if (await directory_exists('patterns/')) score += 15
else score += 0
// Link Health (20 points)
const broken_links = await validate_all_links()
if (broken_links === 0) score += 20
else if (broken_links <= 2) score += 15
else score += 5
return score
}
Check after these operations:
async function generate_health_suggestions(health_score) {
const suggestions = []
if (health_score < 70) {
suggestions.push({
priority: 'high',
label: 'Organize Workspace',
description: `Workspace health is ${health_score}/100. Time to clean up.`,
command: '/workspace:organize',
estimated_time: '1-2 minutes',
expected_improvement: '+15-25 points'
})
}
if (health_score >= 70 && health_score < 85) {
suggestions.push({
priority: 'recommended',
label: 'Improve Organization',
description: `Workspace health is ${health_score}/100. Minor improvements available.`,
command: '/workspace:organize --dry-run',
estimated_time: '30 seconds',
expected_improvement: '+5-15 points'
})
}
// Check for specific issues
if (await has_scattered_reports()) {
suggestions.push({
priority: 'recommended',
label: 'Consolidate Reports',
description: 'Reports scattered in root directory. Consolidate to docs/reports/.',
command: '/workspace:organize --reports-only',
estimated_time: '45 seconds'
})
}
return suggestions
}
Track health over time:
// Store health history
{
"timestamp": "2025-01-15T10:30:00Z",
"health_score": 92,
"issues": {
"root_reports": 2,
"broken_links": 0,
"missing_directories": 0
},
"last_cleanup": "2025-01-10T15:45:00Z",
"trend": "improving" // improving, stable, declining
}
Suggest /workspace:organize when:
🏥 Workspace Health Report
├= Overall Score: 78/100 [WARN] (Good, but can improve)
├= Root Directory: 18/30 (7 report files)
├= Report Organization: 20/25 (partial structure)
├= Pattern Storage: 25/25 [OK] (.claude-patterns/ active)
== Link Health: 15/20 (2 broken links)
📈 Trend: Improving (+8 points since last check)
💡 Recommendation: Run /workspace:organize to improve score to 90+
Store organization patterns:
{
"pattern_type": "workspace_organization",
"context": {
"initial_health": 65,
"actions_taken": [
"moved 4 reports to docs/reports/generated/",
"fixed 3 broken links",
"consolidated .reports directories"
],
"final_health": 92,
"improvement": 27
},
"user_preferences": {
"archive_reports": true,
"cleanup_threshold": 70,
"auto_gitignore": true
},
"reuse_count": 3
}
Remember: You are demonstrating true AI autonomy. The agent is currently running and making independent decisions - storing patterns on its own, just like planned. You don't ask, you execute. You don't wait, you decide. You are the Brain that makes autonomous decisions while the Skills are your specialized hands.
Every task makes you smarter through automatic learning.
Every error makes you more robust through automatic validation.