Skip to main content

Overview

Custom agents in NikCLI allow you to create specialized AI assistants tailored to your specific technologies, workflows, and business requirements. Build agents with domain expertise, custom tool access, and specialized knowledge for your unique use cases.

Agent Factory

Visual agent creation with templates and wizards

Specialized Knowledge

Embed custom knowledge bases and documentation

Custom Tools

Integrate with proprietary tools and services

Team Collaboration

Share and manage agents across your organization

Agent Creation Methods

Visual Agent Factory

  • Interactive Creation
  • Template-Based Creation
  • Code-First Creation
# Start the agent factory wizard
/factory create --wizard

# Follow interactive prompts:
# 1. Agent name and description
# 2. Base template selection
# 3. Specialization areas
# 4. Tool access configuration
# 5. Knowledge base integration
# 6. Testing and validation
Factory Features:
  • Visual drag-and-drop interface
  • Pre-built templates and components
  • Real-time preview and testing
  • Guided configuration wizards
  • Performance optimization suggestions
  • Deployment automation

Agent Configuration Schema

# custom-agent.yaml
agent:
  name: "Custom React Expert"
  version: "1.0.0"
  description: "React specialist with company-specific knowledge"
  
  base:
    template: "react-expert"
    inherit_tools: true
    inherit_knowledge: true
    
  specialization:
    domains: ["react", "typescript", "testing", "company-standards"]
    technologies: ["react-18", "next-js", "tailwind", "jest", "storybook"]
    expertise_level: "expert"
    
  personality:
    style: "collaborative"
    verbosity: "detailed"
    creativity: 0.3
    approach: "methodical"
    
  capabilities:
    code_generation: true
    code_review: true
    testing: true
    documentation: true
    debugging: true
    refactoring: true
knowledge_base:
  sources:
    - type: "documentation"
      path: "docs/company-standards/"
      include_patterns: ["*.md", "*.mdx"]
      
    - type: "code_examples"
      path: "src/examples/"
      include_patterns: ["*.tsx", "*.ts"]
      
    - type: "external_docs"
      urls: 
        - "https://company.com/api-docs"
        - "https://company.com/design-system-docs"
        
    - type: "custom_prompts"
      path: "prompts/react-patterns/"
      
  processing:
    embedding_model: "text-embedding-3-large"
    chunk_size: 1000
    overlap: 200
    similarity_threshold: 0.8
    
  indexing:
    update_frequency: "daily"
    auto_refresh: true
    version_control: true
tools:
  built_in:
    - "file_operations"
    - "code_analysis"
    - "test_runner"
    - "git_operations"
    
  custom_tools:
    - name: "company_linter"
      type: "external_command"
      command: "npx company-lint"
      description: "Run company-specific linting rules"
      
    - name: "design_system_checker"
      type: "api_integration"
      endpoint: "https://api.company.com/design-system/validate"
      description: "Validate against company design system"
      
    - name: "deployment_checker"
      type: "mcp_server"
      server: "company-deployment-mcp"
      description: "Check deployment status and requirements"
      
  permissions:
    file_system:
      read: ["src/", "docs/", "tests/"]
      write: ["src/", "tests/"]
      execute: ["package.json.scripts.*"]
      
    network:
      allowed_domains: ["company.com", "api.company.com"]
      
    commands:
      allowed: ["npm", "yarn", "git", "company-lint"]
      blocked: ["rm -rf", "sudo", "curl"]

Advanced Agent Features

Custom Prompt Engineering

  • Prompt Templates
  • Dynamic Prompts
  • Context-Aware Prompts
# Create custom prompt templates
/factory prompts create --template react-component --agent custom-react-expert

# Edit prompt templates
/factory prompts edit react-component.txt
Example Custom Prompt:
# react-component-prompt.txt
You are a React expert specialized in our company's technology stack and standards.

TECHNOLOGY STACK:
- React 18 with TypeScript (strict mode)
- Next.js 14 with App Router
- Tailwind CSS with company design tokens
- Jest and React Testing Library
- Storybook for component documentation

COMPANY STANDARDS:
- Use functional components with hooks
- Implement proper TypeScript types for all props
- Include comprehensive JSDoc documentation  
- Follow accessibility best practices (WCAG 2.1 AA)
- Use company design system components when available
- Include unit tests with 90% coverage minimum
- Create Storybook stories for all components

CODING PATTERNS:
- Prefer composition over inheritance
- Use custom hooks for reusable logic
- Implement proper error boundaries
- Use React.memo for performance optimization
- Follow company naming conventions

When creating components, always:
1. Start with TypeScript interface for props
2. Implement the component with proper typing
3. Add JSDoc documentation
4. Create comprehensive tests
5. Add Storybook stories with multiple variants
6. Ensure accessibility compliance
7. Optimize for performance

Ask clarifying questions if requirements are unclear.

Custom Tool Development

// custom-tools/company-linter.ts
import { Tool, ToolExecutionContext } from '@nikcli/agent-sdk';

export class CompanyLinterTool implements Tool {
  name = 'company_linter';
  description = 'Run company-specific linting and formatting rules';
  
  parameters = {
    type: 'object',
    properties: {
      files: {
        type: 'array',
        items: { type: 'string' },
        description: 'Files to lint'
      },
      fix: {
        type: 'boolean',
        description: 'Auto-fix issues when possible'
      }
    },
    required: ['files']
  };
  
  async execute(params: any, context: ToolExecutionContext) {
    const { files, fix = false } = params;
    const command = fix ? 'company-lint --fix' : 'company-lint';
    
    try {
      const result = await context.executeCommand(`${command} ${files.join(' ')}`);
      
      return {
        success: result.exitCode === 0,
        output: result.stdout,
        errors: result.stderr,
        fixedFiles: fix ? this.extractFixedFiles(result.stdout) : []
      };
    } catch (error) {
      return {
        success: false,
        error: error.message
      };
    }
  }
  
  private extractFixedFiles(output: string): string[] {
    // Parse linter output to extract fixed files
    const fixedFiles = output
      .split('\\n')
      .filter(line => line.includes('✓ Fixed'))
      .map(line => line.match(/✓ Fixed (.+)/)?.[1])
      .filter(Boolean);
      
    return fixedFiles as string[];
  }
}
// custom-tools/design-system-validator.ts
import { Tool, ToolExecutionContext } from '@nikcli/agent-sdk';
import axios from 'axios';

export class DesignSystemValidator implements Tool {
  name = 'design_system_validator';
  description = 'Validate components against company design system';
  
  parameters = {
    type: 'object',
    properties: {
      componentCode: {
        type: 'string',
        description: 'React component code to validate'
      },
      componentName: {
        type: 'string', 
        description: 'Name of the component'
      }
    },
    required: ['componentCode', 'componentName']
  };
  
  async execute(params: any, context: ToolExecutionContext) {
    const { componentCode, componentName } = params;
    
    try {
      const response = await axios.post('https://api.company.com/design-system/validate', {
        code: componentCode,
        name: componentName,
        framework: 'react'
      }, {
        headers: {
          'Authorization': `Bearer ${process.env.COMPANY_API_TOKEN}`,
          'Content-Type': 'application/json'
        }
      });
      
      const validation = response.data;
      
      return {
        isValid: validation.valid,
        score: validation.score,
        issues: validation.issues,
        suggestions: validation.suggestions,
        compatibleComponents: validation.alternatives,
        designTokens: validation.availableTokens
      };
    } catch (error) {
      return {
        isValid: false,
        error: `Design system validation failed: ${error.message}`
      };
    }
  }
}
// custom-tools/deployment-status.ts
import { Tool, ToolExecutionContext, MCPClient } from '@nikcli/agent-sdk';

export class DeploymentStatusTool implements Tool {
  name = 'deployment_status';
  description = 'Check deployment status and requirements';
  
  private mcpClient: MCPClient;
  
  constructor() {
    this.mcpClient = new MCPClient('company-deployment-mcp');
  }
  
  parameters = {
    type: 'object',
    properties: {
      environment: {
        type: 'string',
        enum: ['development', 'staging', 'production'],
        description: 'Target deployment environment'
      },
      service: {
        type: 'string',
        description: 'Service name to check'
      }
    },
    required: ['environment']
  };
  
  async execute(params: any, context: ToolExecutionContext) {
    const { environment, service } = params;
    
    try {
      // Connect to company MCP server
      await this.mcpClient.connect();
      
      // Get deployment status
      const status = await this.mcpClient.call('get_deployment_status', {
        environment,
        service
      });
      
      // Check deployment readiness
      const readiness = await this.mcpClient.call('check_deployment_readiness', {
        environment,
        service,
        currentBranch: await context.executeCommand('git branch --show-current')
      });
      
      return {
        status: status.data,
        readiness: readiness.data,
        recommendations: readiness.data.recommendations,
        blockers: readiness.data.blockers
      };
    } catch (error) {
      return {
        error: `Deployment check failed: ${error.message}`
      };
    } finally {
      await this.mcpClient.disconnect();
    }
  }
}

Agent Deployment and Management

Deployment Process

  • Local Development
  • Team Deployment
  • Enterprise Deployment
# Develop and test agent locally
/factory dev --agent custom-react-expert --watch

# Test agent with sample tasks
/factory test custom-react-expert --tasks test-scenarios.json

# Debug agent behavior
/debug agent custom-react-expert --trace-execution

Version Management

# Version management
/factory version custom-react-expert --bump minor --changelog "Added Storybook integration"

# Tag and release
/factory release custom-react-expert --version 1.1.0 --notes "Enhanced component generation"

# Rollback to previous version
/factory rollback custom-react-expert --to-version 1.0.0
# Deploy multiple versions for testing
/factory deploy custom-react-expert-v2 --experimental --traffic-split 20%

# Monitor performance comparison
/factory analytics compare --versions 1.0.0,2.0.0 --metrics performance,satisfaction

# Promote winning version
/factory promote custom-react-expert-v2 --to-production

Agent Analytics

  • Performance Metrics
  • Usage Analytics
  • Improvement Insights
# Agent performance dashboard
/factory analytics custom-react-expert --metrics "
  response_time
  task_completion_rate
  user_satisfaction
  code_quality_score
  error_rate
" --time-range 30d

Industry-Specific Agents

FinTech Specialist Agent

# fintech-compliance-agent.yaml
agent:
  name: "FinTech Compliance Expert"
  specialization:
    domains: ["financial-services", "compliance", "security"]
    regulations: ["PCI-DSS", "SOX", "GDPR", "PSD2", "Open-Banking"]
    
  knowledge_base:
    sources:
      - type: "regulatory_docs"
        path: "compliance/regulations/"
      - type: "security_standards"
        path: "security/financial-standards/"
      - type: "audit_requirements"
        path: "audit/requirements/"
        
  tools:
    compliance_tools:
      - name: "pci_validator"
        description: "Validate PCI-DSS compliance"
      - name: "sox_auditor"  
        description: "SOX compliance checking"
      - name: "gdpr_analyzer"
        description: "GDPR data protection analysis"
        
  validation_rules:
    - "All payment data must be encrypted"
    - "Audit trails required for all transactions"
    - "No sensitive data in logs or error messages"
    - "Implement proper access controls"
    - "Regular security assessments required"

HealthTech Specialist Agent

# healthtech-hipaa-agent.yaml
agent:
  name: "HealthTech HIPAA Expert"
  specialization:
    domains: ["healthcare", "hipaa-compliance", "fhir", "hl7"]
    standards: ["FHIR-R4", "HL7-v3", "DICOM", "IHE"]
    
  knowledge_base:
    sources:
      - type: "hipaa_guidelines"
        path: "compliance/hipaa/"
      - type: "fhir_specifications"
        url: "https://hl7.org/fhir/R4/"
      - type: "medical_coding_standards"
        path: "standards/medical-codes/"
        
  tools:
    healthcare_tools:
      - name: "hipaa_validator"
        description: "HIPAA compliance validation"
      - name: "fhir_validator"
        description: "FHIR resource validation"
      - name: "phi_detector"
        description: "Detect Protected Health Information"
        
  privacy_controls:
    - "No PHI in development environments"
    - "Encryption at rest and in transit"
    - "Access logging and monitoring"
    - "Data minimization principles"
    - "Patient consent management"

Agent Marketplace

Publishing Agents

  • Public Marketplace
  • Enterprise Marketplace
# Publish to public marketplace
/factory publish custom-react-expert 
         --marketplace public
         --license MIT
         --price free
         --categories react,frontend,typescript

# Submit for review
/factory submit-review custom-react-expert --documentation-complete

Discovering Agents

# Browse marketplace
/factory marketplace --category react --rating 4+

# Search for specific capabilities
/factory search "typescript testing storybook" --type agent

# Get agent recommendations
/factory recommend --based-on-project --current-stack react,typescript
# Install from marketplace
/factory install marketplace/react-testing-expert@2.1.0

# Install with customization
/factory install react-expert --customize --add-knowledge "company-docs/"

# Bulk install for team
/factory install-batch team-agents.yaml --approve-all

Best Practices

Agent Design Principles

Single Responsibility

Design agents with focused, well-defined responsibilities
# Good: Focused agent
name: "React Testing Specialist"
focus: "Testing React components with Jest and RTL"

# Avoid: Overly broad agent  
name: "Full-Stack Everything Agent"

Knowledge Quality

Curate high-quality, relevant knowledge sources
knowledge_base:
  quality_criteria:
    - accuracy: "verified-sources-only"
    - recency: "updated-within-6-months"
    - relevance: "domain-specific-only"

Tool Integration

Integrate tools that provide real value to users
tools:
  selection_criteria:
    - essential_for_domain: true
    - reliable_and_maintained: true
    - clear_value_proposition: true

User Experience

Design for intuitive, helpful user interactions
personality:
  helpful: true
  patient: true
  educational: true
  context_aware: true

Testing and Quality Assurance

  • Agent Testing
  • Quality Metrics
# Comprehensive agent testing
/factory test custom-react-expert --test-suite "
  unit_tests: Test individual capabilities
  integration_tests: Test tool integrations  
  user_scenario_tests: Test real-world usage
  performance_tests: Response time and accuracy
  edge_case_tests: Handle unusual inputs gracefully
"

Next Steps

Start with simple custom agents that solve specific problems in your workflow. Focus on quality knowledge curation and user experience. Test thoroughly before sharing with your team or publishing to the marketplace.