Skip to main content

Overview

NikCLI provides powerful terminal operation capabilities that allow you to execute system commands, manage processes, and interact with your development environment directly from the chat interface. All terminal operations include built-in security policies and approval workflows.

Command Execution

Execute terminal commands with security policies

Process Management

Monitor and control running processes

Security Policies

Built-in protection against harmful commands

Output Streaming

Real-time command output with progress tracking

Terminal Commands

/run - Execute Commands

Execute terminal commands with built-in security and approval workflows.
  • Basic Usage
  • Advanced Options
  • Interactive Commands
# Basic command execution
/run ls -la
/run pwd
/run whoami

# Development commands
/run npm install
/run npm test
/run npm run build

# Git operations
/run git status
/run git add .
/run git commit -m "Update documentation"

/sh - Shell Alias

Convenient alias for /run command with identical functionality.
# These commands are equivalent
/sh npm test
/run npm test

# Shell scripting
/sh "cd src && find . -name '*.ts' | wc -l"
/sh "grep -r 'TODO' src/ | head -10"

/kill - Process Management

Terminate running background processes by PID or name.
# Kill specific process by PID
/kill 1234
/kill 5678

# Kill with specific signal
/kill -TERM 1234
/kill -KILL 5678
/kill -USR1 9999
# Kill processes by name
/kill node
/kill "npm run dev"
/kill docker-compose

# Kill all matching processes
/kill --all node
/kill --pattern "npm.*dev"
# List running processes
/kill --list

# Interactive process selection
/kill --interactive

# Show process tree
/kill --tree

/ps - Process List

Display running processes with filtering and sorting options.
# List all processes
/ps

# List processes by user
/ps --user $(whoami)

# List processes by name pattern
/ps --name node
/ps --pattern "npm.*"

# List with detailed information
/ps --detailed
/ps --tree
/ps --sort cpu
/ps --sort memory

/env - Environment Variables

Manage environment variables for the current session.
  • View Variables
  • Set Variables
  • Advanced Management
# Show all environment variables
/env

# Show specific variables
/env PATH
/env NODE_ENV
/env API_KEY

# Search variables by pattern
/env --pattern "npm.*"
/env --pattern ".*key.*"

/pwd - Working Directory

Display and manage the current working directory.
# Show current directory
/pwd

# Show with full path resolution
/pwd --resolved

# Show directory tree
/pwd --tree

# Show directory with git status
/pwd --git

/cd - Change Directory

Change the working directory for subsequent commands.
# Change to specific directory
/cd /path/to/project
/cd ~/Documents/projects
/cd ./src/components

# Navigate relative to current directory
/cd ..
/cd ../..
/cd ./nested/folder

# Go to home directory
/cd ~
/cd
# Auto-complete with Tab key
/cd src/comp[Tab] /cd src/components/

# Navigate to git root
/cd --git-root

# Navigate to project root (finds package.json, etc.)
/cd --project-root

# Navigate to previous directory
/cd -
# Show directory history
/cd --history

# Navigate to recent directory by index
/cd --history 2
/cd --history 5

# Clear directory history
/cd --clear-history

/which - Command Location

Find the location of executable commands and check availability.
# Find command location
/which node
/which npm
/which git
/which docker

# Check multiple commands
/which node npm git python

# Show all matching executables
/which --all python

# Check command exists
/which --exists docker-compose

/exec - Execute with Context

Execute commands with enhanced context awareness and logging.
  • Context Execution
  • Conditional Execution
  • Pipeline Execution
# Execute with project context
/exec npm test
/exec yarn build
/exec docker-compose up

# Execute with enhanced logging
/exec --log npm run build
/exec --verbose docker build .

# Execute with performance monitoring
/exec --profile npm run build
/exec --time ./benchmark.sh

Security Policies

Command Approval

NikCLI implements multi-level command approval based on risk assessment:
  • Safe Commands
  • Moderate Risk
  • High Risk
  • Blocked Commands
Automatically Approved:
ls, pwd, whoami, cat, grep, find
npm test, npm run build, npm install
git status, git log, git diff
node --version, npm --version

Security Modes

Configure security levels for different development scenarios:
/safe-mode
Characteristics:
  • Maximum security restrictions
  • Approval required for all file modifications
  • No system-level commands
  • Sandboxed execution environment
  • Comprehensive audit logging
/dev-mode enable 60  # Enable for 60 minutes
Characteristics:
  • Reduced security restrictions
  • Streamlined approval process
  • Access to system commands
  • Enhanced development tools
  • Time-limited activation
/security set approval-mode selective
/security set command-execution restricted
/security set file-operations safe
Options:
  • approval-mode: none, selective, strict
  • command-execution: blocked, restricted, allowed
  • file-operations: readonly, safe, unrestricted

Command Output Management

Streaming Output

Real-time command output with progress tracking:
# Stream output in real-time
/run --stream npm run build
/run --stream docker build .
/run --stream npm test -- --watch

# Control output buffering
/run --buffer-lines 100 npm run build
/run --no-buffer tail -f log.txt

Output Formatting

Control how command output is displayed:
  • Display Options
  • Output Processing
# Syntax highlighting for common outputs
/run --highlight cat package.json
/run --highlight git log --oneline

# Compact output format
/run --compact npm list
/run --compact docker ps

# Verbose output with metadata
/run --verbose npm run build
/run --debug docker-compose up

Output History

Access and manage command output history:
# Show recent command outputs
/output list
/output history

# View specific command output
/output show 123
/output replay "npm run build"

# Search output history
/output search "error"
/output grep "warning"

# Export output
/output export build-logs.txt
/output save 123 command-output.txt

Process Monitoring

Background Process Management

Monitor and manage long-running processes:
# Start development server in background
/run --background npm run dev
/run --bg docker-compose up
/run --daemon pm2 start app.js

# Start with custom process name
/run --background --name "dev-server" npm run dev
/run --bg --name "api-server" node server.js
# List background processes
/process list
/process status

# Show detailed process information
/process info dev-server
/process logs api-server

# Monitor process resources
/process monitor
/process top
# Stop background processes
/process stop dev-server
/process kill api-server

# Restart processes
/process restart dev-server
/process reload api-server

# Process health checks
/process health
/process ping dev-server

Performance Monitoring

Track resource usage and performance metrics:
# System resource usage
/monitor cpu
/monitor memory
/monitor disk
/monitor network

# Process-specific monitoring
/monitor process dev-server
/monitor --pid 1234

# Performance profiling
/profile npm run build
/profile --flame-graph node app.js
/profile --memory-usage npm test

Integration with Development Tools

Package Managers

Enhanced support for common package managers:
  • npm Integration
  • yarn Integration
  • pnpm Integration
# Smart npm commands
/npm install express
/npm run build
/npm test -- --coverage

# npm with enhanced features
/npm --profile install  # Profile installation
/npm --verify audit     # Verify after audit
/npm --update outdated  # Update outdated packages

Version Control

Git integration with enhanced features:
# Git with context awareness
/git status --porcelain
/git diff --staged
/git log --graph --oneline

# Smart git operations
/git --auto-stage commit -m "Update features"
/git --interactive rebase HEAD~3
/git --force-with-lease push origin main
# Feature branch workflow
/git feature start new-feature
/git feature finish new-feature

# Hotfix workflow
/git hotfix start critical-bug
/git hotfix finish critical-bug

# Release workflow
/git release start v1.2.0
/git release finish v1.2.0

Docker Integration

Container management with enhanced monitoring:
# Docker commands with enhancements
/docker ps --format "table"
/docker logs --follow --tail 100 container
/docker exec -it container /bin/bash

# Docker Compose integration
/docker-compose --profile dev up
/docker-compose logs --follow service
/docker-compose exec service bash

# Container health monitoring
/docker health container-name
/docker stats --no-stream
/docker system df

Best Practices

Security Best Practices

Command Verification

Always review commands before execution, especially in production environments
# Use --dry-run when available
/run --dry-run rm -rf old-files/
/run --preview docker-compose up

Environment Isolation

Use proper environment separation and variable management
# Isolate environments
/env --file .env.development
/run --env-file .env.production npm run deploy

Output Sanitization

Be cautious with sensitive information in command outputs
# Mask sensitive outputs
/run --mask-secrets env
/run --no-log curl -H "Authorization: Bearer $TOKEN"

Audit Logging

Maintain comprehensive audit logs for security compliance
# Enable detailed logging
/security audit enable
/run --audit-log critical-operation.sh

Performance Optimization

  • Command Optimization
  • Output Management
  • Process Management
# Use efficient commands
/run --parallel npm run build:components
/run --jobs 4 npm run test

# Optimize resource usage
/run --memory-limit 1G node build.js
/run --cpu-limit 0.5 npm run build

Troubleshooting

Common Issues

Problem: Command execution fails with “command not found”Solutions:
# Check command availability
/which command-name

# Check PATH environment
/env PATH

# Use full path
/run /usr/local/bin/node --version

# Install missing commands
/run which brew && brew install missing-package
Problem: Command fails due to insufficient permissionsSolutions:
# Check file permissions
/run ls -la file-or-directory

# Use appropriate permissions
/run chmod +x script.sh

# Run with proper user context
/run --user $(whoami) command

# Use sudo when necessary (with approval)
/run sudo command  # Requires approval
Problem: Commands hang or become unresponsiveSolutions:
# Use timeout
/run --timeout 30 slow-command

# Run in background with monitoring
/run --background --monitor npm run dev

# Kill hanging processes
/kill --pattern "hanging-process"
/process kill --force process-name
Problem: Large output causes memory or display issuesSolutions:
# Limit output
/run --head 100 command-with-large-output

# Stream output
/run --stream --buffer-lines 50 npm run build

# Save to file
/run --save output.txt command

Debugging Commands

Enable detailed debugging for command execution:
# Enable debug mode
/debug terminal enable

# Show command parsing
/debug command "npm run build"

# Trace command execution
/trace /run npm test

# Profile command performance
/profile --detailed npm run build

# Inspect security policies
/debug security check "rm file.txt"

Next Steps

Use /run --help to see all available options for command execution. The help system is context-aware and will show relevant flags based on your current environment and security settings.