How seojoonkim/agentlinter works
Purpose and Entry Points
AgentLinter is a local-first TypeScript linter for AI-agent workspace instructions. It discovers configuration files, evaluates them for quality, safety, consistency, and token cost, then produces scores, diagnostics, fixes, exports, and optionally shareable reports.
Primary executable entry point: packages/cli/src/bin.ts. The website/report application is a Next.js App Router app rooted at src/app/page.tsx; report viewing is served at src/app/r/[id]/page.tsx.
CLI Orchestration
The CLI delegates workspace analysis to a packaged engine and controls user-facing commands such as linting, fixes, report sharing, initialization, and framework export.
• packages/cli/src/bin.ts
• packages/cli/src/engine/index.ts
• packages/cli/src/upload.ts
The CLI boundary is intentionally separate from the web engine implementation, with a narrower rule set and framework exporters under packages/cli/src/engine/frameworks/.
Workspace Discovery and Parsing
Analysis begins by locating supported agent configuration files and interpreting their contents into shared workspace/file models. Detection supports Claude Code-style files, agent-memory files, skills, runtime configs, and other framework conventions; mode detection influences applicable recommendations.
• src/engine/parser.ts
• src/engine/types.ts
• src/engine/index.ts
This is the main boundary between arbitrary filesystem content and normalized, analyzable workspace data.
Rules and Diagnostics Pipeline
The engine runs composable rule modules over parsed workspace data. Rules emit diagnostics with severity, category, suggested remediation, and potentially auto-fix metadata. Rule groups cover structural quality, clarity, completeness, cross-file consistency, memory, runtime configuration, skill safety, security/secrets, instruction/token budgets, freshness/import integrity, and cognitive blueprints.
• src/engine/rules/index.ts
• src/engine/rules/security.ts
• src/engine/rules/orchestration.ts
Rule orchestration is the core extension point: adding a policy generally means adding a rule module and registering it in the rules index.
Scoring, Budgeting, and Deep Analysis
Diagnostics are aggregated into category and overall scores by the scorer, while budget logic measures instruction/token usage. A v2 analyzer provides higher-level analysis beyond individual violations, such as cognitive load, token distribution, modularity, role complexity, and deeper security inspection.
• src/engine/scorer.ts
• src/engine/budget.ts
• src/engine/v2/analyzer.ts
These calculations form the contract consumed by both CLI rendering and web report presentation.
Reporting and Sharing APIs
The engine reporter transforms analysis results into report-ready output. The web app exposes report creation/retrieval and a score-to-SVG badge endpoint; report-specific UI loads an ID-based report and renders score, categories, diagnostics, and methodology tabs.
• src/engine/reporter.ts
• src/app/api/reports/route.ts
• src/app/api/reports/[id]/route.ts
• src/app/api/badge/route.ts
Persistence/external service integration is represented by Supabase via src/lib/supabase.ts; CLI sharing uploads report metadata through packages/cli/src/upload.ts. File contents are intended to remain local while shareable report metadata is transmitted.
Web Report Experience and Runtime
The frontend is Next.js/React with server routes and client-side report visualization. The analysis landing experience is at src/app/analyze/page.tsx; report interactivity is isolated in src/app/r/[id]/ReportClient.tsx and its tab components. Deployment configuration indicates Vercel compatibility through next.config.ts and .vercelignore.
Material runtimes: Node.js 18+, TypeScript, a Node-distributed CLI, and Next.js for the hosted report site. External surfaces are Supabase-backed report storage and the public badge/report HTTP APIs.
Main entry points: engine/index.ts Engine API · supabase.ts Supabase client · rules/index.ts Rule registry · route.ts Reports API
Components 21
CLI distribution
Local Node.js command surface.
- CLI entry point · Runs lint, fix, init, export, and share commands.
packages/cli/src/bin.ts - Packaged CLI engine · CLI-specific engine boundary with narrower rules and exporters.
packages/cli/src/engine/index.ts - Report upload · Transmits shareable report metadata without file contents.
packages/cli/src/upload.ts
Analysis engine
Shared workspace analysis pipeline.
- Engine API · Coordinates normalized workspace analysis.
src/engine/index.ts - Discovery and parser · Finds supported instruction files and normalizes workspace data.
src/engine/parser.ts - Workspace models
src/engine/types.ts - Rule registry · Registers composable policies and collects diagnostics.
src/engine/rules/index.ts - Security rules · Checks secrets and safety concerns.
src/engine/rules/security.ts - Orchestration rules · Checks instruction structure and agent coordination.
src/engine/rules/orchestration.ts - Scorer · Computes category and overall scores.
src/engine/scorer.ts - Token budget · Measures instruction and token usage.
src/engine/budget.ts - Deep analyzer · Assesses cognitive load, modularity, complexity, and deeper security.
src/engine/v2/analyzer.ts - Report builder · Converts analysis results into report-ready output.
src/engine/reporter.ts
Next.js report app
Hosted report and API surface.
- Analysis landing
src/app/analyze/page.tsx - Report viewer · Loads an ID-based shared report.
src/app/r/[id]/page.tsx - Report visualization · Renders score, categories, diagnostics, and methodology tabs.
src/app/r/[id]/ReportClient.tsx - Reports API · Creates shareable reports.
src/app/api/reports/route.ts - Report retrieval API · Retrieves a report by ID.
src/app/api/reports/[id]/route.ts - Badge API · Produces score SVG badges.
src/app/api/badge/route.ts
External service
- Supabase client · Connects report APIs to report storage.
src/lib/supabase.ts - Supabase · Stores shareable report metadata.
Connections 22
- CLI entry point → Packaged CLI engine: runs analysis
- CLI entry point → Report upload: share command
- Packaged CLI engine → Engine API: analysis contract
- Engine API → Discovery and parser: discovers and parses
- Discovery and parser → Workspace models: normalizes into
- Engine API → Rule registry: evaluates workspace
- Rule registry → Security rules: includes
- Rule registry → Orchestration rules: includes
- Engine API → Scorer: aggregates diagnostics
- Engine API → Token budget: measures usage
- Engine API → Deep analyzer: runs deep analysis
- Scorer → Report builder: scores
- Token budget → Report builder: budgets
- Deep analyzer → Report builder: insights
- Analysis landing → Reports API: creates report
- Report upload → Reports API: uploads metadata
- Reports API → Supabase client: persists through
- Report retrieval API → Supabase client: reads through
- Badge API → Supabase client: reads score through
- Supabase client → Supabase: connects to
- Report viewer → Report retrieval API: loads report
- Report viewer → Report visualization: renders with