Skip to content

Internals

How claudelint works under the hood: parallel validation, caching, the CLI architecture, and diagnostic collection.

Parallel Validation

All validators run concurrently using Promise.all() in check-all.ts. Each validator (CLAUDE.md, Skills, Agents, etc.) executes independently, so total wall-clock time equals the slowest validator rather than the sum of all.

typescript
// Simplified from src/cli/commands/check-all.ts
const enabledValidators = ValidatorRegistry.getAllMetadata().filter((m) => m.enabled);

const results = await Promise.all(
  enabledValidators.map((metadata) =>
    reporter.runValidator(metadata.name, () =>
      ValidatorRegistry.create(metadata.id, options).validate()
    )
  )
);

Progress output adapts to the environment automatically: animated spinners in terminals, plain text in CI (detected via CI, GITHUB_ACTIONS, and similar env vars), and no output in JSON mode.

Caching

The ValidationCache class caches validation results keyed by validator name. Cache entries are invalidated when the claudelint version, configuration, or validated file modification times change. For CLI flags and CI setup, see the CI/CD Integration Guide.

typescript
// src/utils/cache.ts
export interface CacheOptions {
  enabled: boolean;
  location: string;          // Default: '.claudelint-cache'
  strategy: 'content' | 'mtime';
}

export class ValidationCache {
  get(validatorName: string, config?: unknown): ValidationResult | null;
  set(validatorName: string, result: ValidationResult, config?: unknown): void;
  clear(): void;
}

CLI Implementation

The CLI uses Commander.js for argument parsing. The entrypoint is src/cli.ts and commands are organized in src/cli/commands/:

CommandSourceDescription
check-allcheck-all.tsRun all validators (parallel execution)
validate-*validator-commands.tsFactory for individual validator commands
explainexplain.tsExplain a rule in detail
list-ruleslist-rules.tsList all available rules
check-deprecatedcheck-deprecated.tsList deprecated rules in config
migratemigrate.tsAuto-migrate deprecated rules
formatformat.tsFormat Claude Code files
cache-clearcache-clear.tsClear validation cache
configconfig-commands.tsConfig inspection commands
install-plugininstall-plugin.tsPlugin installation
watchwatch.tsWatch mode for file changes

Individual validator commands are created through a factory in validator-commands.ts to eliminate duplication. Each command follows the same pattern: load config, create validator, run validation, report results.

Diagnostic Collection

Library code uses DiagnosticCollector instead of console directly:

typescript
// src/utils/diagnostics/collector.ts
export class DiagnosticCollector {
  warn(message: string, source: string, code?: string): void;
  error(message: string, source: string, code?: string): void;
  info(message: string, source: string, code?: string): void;
  getWarnings(): Diagnostic[];
  getErrors(): Diagnostic[];
  getAll(): Diagnostic[];
}

This makes the library testable, supports programmatic usage, and provides structured diagnostics with source tracking.