Skip to main content

Command Overview

The InitRepo CLI provides comprehensive commands for code analysis, documentation generation, and safe code modifications. All commands support both human-readable and JSON output formats for seamless AI integration.

Command Categories

Analysis Commands

Deep codebase analysis including structure, complexity, and quality metrics

Generation Commands

Automated documentation and structure generation from code analysis

Modification Commands

Safe code modifications using AST-based operations

Utility Commands

Project scaffolding, configuration, and task management

Core Analysis Commands

analyze

Performs comprehensive codebase analysis and creates a .initrepo/ directory with results.
# Basic analysis
initrepo-cli analyze

# Analysis with JSON output
initrepo-cli analyze --format=json

# Include specific patterns
initrepo-cli analyze --include "src/**/*.js"

# Exclude patterns
initrepo-cli analyze --exclude "**/*.test.js"
Options:
  • --format: Output format (text, json)
  • --include: Include file patterns
  • --exclude: Exclude file patterns
  • --max-depth: Maximum directory depth
  • --verbose: Detailed output

generate-structure

Creates visual project structure documentation.
# Human-readable tree view
initrepo-cli generate-structure --format=tree

# Limited depth
initrepo-cli generate-structure --format=tree --max-depth=3

# Save to file
initrepo-cli generate-structure --format=tree > project-structure.txt
Options:
  • --format: tree, json
  • --max-depth: Maximum directory depth (default: 5)
  • --output: Output file path
  • --include-hidden: Include hidden files and directories

analyze-complexity

Analyzes code complexity and identifies potential issues.
# Basic complexity analysis
initrepo-cli analyze-complexity

# Set complexity threshold
initrepo-cli analyze-complexity --threshold=15

# With recommendations
initrepo-cli analyze-complexity --with-recommendations

# JSON output for AI processing
initrepo-cli analyze-complexity --format=json
Options:
  • --threshold: Complexity threshold (default: 10)
  • --with-recommendations: Include improvement suggestions
  • --format: text, json
  • --include: File patterns to analyze
  • --exclude: File patterns to exclude

analyze-imports

Analyzes import statements and identifies issues.
# Full import analysis
initrepo-cli analyze-imports

# Find unused imports only
initrepo-cli analyze-imports --unused-only

# Check for circular dependencies
initrepo-cli analyze-imports --circular-only

# JSON format for automation
initrepo-cli analyze-imports --format=json
Options:
  • --unused-only: Show only unused imports
  • --circular-only: Show only circular dependencies
  • --format: text, json
  • --fix: Automatically fix issues (use with caution)

validate-structure

Validates project structure against best practices.
# Basic validation
initrepo-cli validate-structure

# Strict validation
initrepo-cli validate-structure --strict

# JSON output with score
initrepo-cli validate-structure --format=json
Output includes:
  • Structure score (0-100)
  • Best practice violations
  • Improvement recommendations
  • Compliance status

Documentation Commands

deps

Analyzes and documents project dependencies.
# All dependencies
initrepo-cli deps

# Runtime dependencies only
initrepo-cli deps --type=runtime

# Development dependencies only
initrepo-cli deps --type=dev
# Markdown table format
initrepo-cli deps --format=markdown

# JSON format
initrepo-cli deps --format=json

# Export to file
initrepo-cli deps --format=json > dependencies.json

find-symbol

Searches for symbols (functions, classes, variables) in the codebase.
# Find all occurrences of a symbol
initrepo-cli find-symbol "getUserById"

# Find by symbol type
initrepo-cli find-symbol "User" --type=class

# Exact match only
initrepo-cli find-symbol "authenticate" --exact

# JSON output
initrepo-cli find-symbol "validateInput" --format=json
Options:
  • --type: Symbol type (function, class, variable, interface)
  • --exact: Exact matching only
  • --case-sensitive: Case-sensitive search
  • --format: text, json

get-code

Extracts code blocks with context.
# Get function with minimal context
initrepo-cli get-code "processPayment"

# Get with full context
initrepo-cli get-code "UserService" --context=full

# JSON format for AI processing
initrepo-cli get-code "validateUser" --context=minimal --format=json
Context levels:
  • minimal: Function/class only
  • dependencies: Include immediate dependencies
  • full: Include complete context and relationships

Safe Modification Commands

safe-rename

Safely renames symbols throughout the codebase using AST analysis.
1

Preview Changes

# Preview rename operation
initrepo-cli safe-rename oldFunctionName newFunctionName --dry-run
2

Apply Rename

# Apply the rename
initrepo-cli safe-rename oldFunctionName newFunctionName

# With backup
initrepo-cli safe-rename oldFunctionName newFunctionName --backup
3

Verify Changes

# Find references to new name
initrepo-cli find-references newFunctionName
Options:
  • --dry-run: Preview changes without applying
  • --backup: Create backup before changes
  • --scope: Limit scope (file, directory, project)
  • --format: text, json

manage-imports

Manages import statements automatically.
# Remove unused imports
initrepo-cli manage-imports --remove-unused

# Organize imports
initrepo-cli manage-imports --organize

# Both operations
initrepo-cli manage-imports --remove-unused --organize

# Preview changes
initrepo-cli manage-imports --remove-unused --dry-run
Options:
  • --remove-unused: Remove unused import statements
  • --organize: Sort and group imports
  • --dry-run: Preview changes
  • --backup: Create backup before changes

Utility Commands

scaffold

Creates new projects with best practices and templates.
# React application
initrepo-cli scaffold react my-app

# Next.js application
initrepo-cli scaffold nextjs web-app

# Node.js API
initrepo-cli scaffold node-api api-server

# Vue.js application
initrepo-cli scaffold vue my-vue-app

# Angular application
initrepo-cli scaffold angular admin-panel
Options:
  • Project templates are pre-configured with best practices
  • Includes package.json, configuration files, and basic project structure
  • Ready for immediate development and deployment

suggest-refactor

Provides AI-powered refactoring suggestions.
# All suggestions
initrepo-cli suggest-refactor

# High priority only
initrepo-cli suggest-refactor --min-severity=high

# Specific categories
initrepo-cli suggest-refactor --category=performance

# JSON format
initrepo-cli suggest-refactor --format=json
Categories:
  • performance: Performance improvements
  • maintainability: Code maintainability
  • security: Security enhancements
  • style: Code style consistency

find-references

Finds all references to a symbol.
# Find all references
initrepo-cli find-references "calculateTotal"

# Include definitions
initrepo-cli find-references "User" --include-definitions

# JSON output
initrepo-cli find-references "validateInput" --format=json

Global Options

All commands support these global options:
# Common options across all commands
initrepo-cli <command> [options]
  --help          Show help for command
  --version       Show CLI version
  --format        Output format: text, json
  --output        Output to file
  --verbose       Verbose output
  --quiet         Suppress non-error output
  --dry-run       Preview changes without applying (where applicable)

Advanced Usage Examples

Automated Quality Analysis

#!/bin/bash
# quality-check.sh - Comprehensive quality assessment

echo "🔍 Running automated quality checks..."

# Structure validation
initrepo-cli validate-structure --format=json > validation.json

# Complexity analysis
initrepo-cli analyze-complexity --threshold=15 --format=json > complexity.json

# Import analysis
initrepo-cli analyze-imports --format=json > imports.json

# Generate report
echo "✅ Quality check complete. Check JSON files for results."

CI/CD Integration

# GitHub Actions workflow
- name: InitRepo Analysis
  run: |
    initrepo-cli validate-structure --format=json > structure.json
    initrepo-cli analyze-complexity --threshold=10 --format=json > complexity.json
    
    # Quality gates
    score=$(jq '.data.score' structure.json)
    if [ "$score" -lt 80 ]; then
      echo "Structure score too low: $score/100"
      exit 1
    fi

AI Assistant Integration

# Generate AI-ready context
initrepo-cli analyze --format=json > project-context.json
initrepo-cli get-code "UserService" --context=full --format=json >> ai-context.json

# Use with AI coding assistants
cat ai-context.json | ai-assistant "Analyze this code structure"

Command Aliases

Common command aliases for faster usage:
# Add to your shell profile (.bashrc, .zshrc)
alias ira="initrepo-cli analyze"
alias irgs="initrepo-cli generate-structure"
alias irac="initrepo-cli analyze-complexity"
alias irai="initrepo-cli analyze-imports"
alias irsr="initrepo-cli safe-rename"

Best Practices

For Development Workflow

  1. Run analysis regularly: initrepo-cli analyze should be part of your development routine
  2. Use JSON output: Enable better integration with scripts and AI assistants
  3. Preview before modifying: Always use --dry-run for modification commands
  4. Set appropriate thresholds: Adjust complexity thresholds based on your project needs

For Team Collaboration

  1. Standardize configurations: Use consistent .initrepoignore files across team
  2. Integrate with CI/CD: Automate quality checks in your pipelines
  3. Share JSON outputs: Use structured outputs for team analysis and reporting
  4. Document decisions: Use refactoring suggestions to document architectural decisions

Next Steps