# seojoonkim/agentlinter architecture

> Architecture diagram of the GitHub repository seojoonkim/agentlinter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/seojoonkim/agentlinter
- Repository: https://github.com/seojoonkim/agentlinter

## Overview

#### 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: [`src/engine/index.ts`](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/index.ts) (Engine API), [`src/lib/supabase.ts`](https://github.com/seojoonkim/agentlinter/blob/main/src/lib/supabase.ts) (Supabase client), [`src/engine/rules/index.ts`](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/index.ts) (Rule registry), [`src/app/api/reports/route.ts`](https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/reports/route.ts) (Reports API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI distribution"]
  node_cli_bin["CLI entry point<br/>TypeScript CLI<br/>[bin.ts]"]
  node_cli_engine["Packaged CLI engine<br/>analysis adapter<br/>[index.ts]"]
  node_cli_upload["Report upload<br/>sharing client<br/>[upload.ts]"]
end

subgraph group_engine["Analysis engine"]
  node_engine_api["Engine API<br/>analysis facade<br/>[index.ts]"]
  node_parser["Discovery and parser<br/>filesystem parser<br/>[parser.ts]"]
  node_workspace_types["Workspace models<br/>TypeScript models<br/>[types.ts]"]
  node_rules["Rule registry<br/>rule orchestration<br/>[index.ts]"]
  node_security_rules["Security rules<br/>rule module<br/>[security.ts]"]
  node_orchestration_rules["Orchestration rules<br/>rule module<br/>[orchestration.ts]"]
  node_scorer["Scorer<br/>diagnostic aggregation<br/>[scorer.ts]"]
  node_budget["Token budget<br/>usage analysis<br/>[budget.ts]"]
  node_v2_analyzer["Deep analyzer<br/>v2 analysis<br/>[analyzer.ts]"]
  node_reporter["Report builder<br/>report transformation<br/>[reporter.ts]"]
end

subgraph group_web["Next.js report app"]
  node_analyze_page["Analysis landing<br/>Next.js page<br/>[page.tsx]"]
  node_report_page["Report viewer<br/>Next.js page<br/>[page.tsx]"]
  node_report_client["Report visualization<br/>React client<br/>[ReportClient.tsx]"]
  node_reports_api["Reports API<br/>Next.js route<br/>[route.ts]"]
  node_report_api["Report retrieval API<br/>Next.js route<br/>[route.ts]"]
  node_badge_api["Badge API<br/>Next.js route<br/>[route.ts]"]
end

subgraph group_external["External service"]
  node_supabase_client[("Supabase client<br/>persistence client<br/>[supabase.ts]")]
  node_supabase[("Supabase<br/>report storage")]
end

node_cli_bin -->|"runs analysis"| node_cli_engine
node_cli_bin -->|"share command"| node_cli_upload
node_cli_engine -.->|"analysis contract"| node_engine_api
node_engine_api -->|"discovers and parses"| node_parser
node_parser -->|"normalizes into"| node_workspace_types
node_engine_api -->|"evaluates workspace"| node_rules
node_rules -->|"includes"| node_security_rules
node_rules -->|"includes"| node_orchestration_rules
node_engine_api -->|"aggregates diagnostics"| node_scorer
node_engine_api -->|"measures usage"| node_budget
node_engine_api -->|"runs deep analysis"| node_v2_analyzer
node_scorer -->|"scores"| node_reporter
node_budget -->|"budgets"| node_reporter
node_v2_analyzer -->|"insights"| node_reporter
node_analyze_page -->|"creates report"| node_reports_api
node_cli_upload -->|"uploads metadata"| node_reports_api
node_reports_api -->|"persists through"| node_supabase_client
node_report_api -->|"reads through"| node_supabase_client
node_badge_api -->|"reads score through"| node_supabase_client
node_supabase_client -->|"connects to"| node_supabase
node_report_page -->|"loads report"| node_report_api
node_report_page -->|"renders with"| node_report_client

click node_cli_bin "https://github.com/seojoonkim/agentlinter/blob/main/packages/cli/src/bin.ts"
click node_cli_engine "https://github.com/seojoonkim/agentlinter/blob/main/packages/cli/src/engine/index.ts"
click node_cli_upload "https://github.com/seojoonkim/agentlinter/blob/main/packages/cli/src/upload.ts"
click node_engine_api "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/index.ts"
click node_parser "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/parser.ts"
click node_workspace_types "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/types.ts"
click node_rules "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/index.ts"
click node_security_rules "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/security.ts"
click node_orchestration_rules "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/orchestration.ts"
click node_scorer "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/scorer.ts"
click node_budget "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/budget.ts"
click node_v2_analyzer "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/v2/analyzer.ts"
click node_reporter "https://github.com/seojoonkim/agentlinter/blob/main/src/engine/reporter.ts"
click node_analyze_page "https://github.com/seojoonkim/agentlinter/blob/main/src/app/analyze/page.tsx"
click node_report_page "https://github.com/seojoonkim/agentlinter/blob/main/src/app/r/%5Bid%5D/page.tsx"
click node_report_client "https://github.com/seojoonkim/agentlinter/blob/main/src/app/r/%5Bid%5D/ReportClient.tsx"
click node_reports_api "https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/reports/route.ts"
click node_report_api "https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/reports/%5Bid%5D/route.ts"
click node_badge_api "https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/badge/route.ts"
click node_supabase_client "https://github.com/seojoonkim/agentlinter/blob/main/src/lib/supabase.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli_bin,node_cli_engine,node_cli_upload toneBlue
class node_engine_api,node_parser,node_workspace_types,node_rules,node_security_rules,node_orchestration_rules,node_scorer,node_budget,node_v2_analyzer,node_reporter toneAmber
class node_analyze_page,node_report_page,node_report_client,node_reports_api,node_report_api,node_badge_api toneMint
class node_supabase_client,node_supabase toneRose
```

## Components

### CLI distribution

Local Node.js command surface.

- [CLI entry point](https://github.com/seojoonkim/agentlinter/blob/main/packages/cli/src/bin.ts): TypeScript CLI · Runs lint, fix, init, export, and share commands. · `packages/cli/src/bin.ts`
- [Packaged CLI engine](https://github.com/seojoonkim/agentlinter/blob/main/packages/cli/src/engine/index.ts): analysis adapter · CLI-specific engine boundary with narrower rules and exporters. · `packages/cli/src/engine/index.ts`
- [Report upload](https://github.com/seojoonkim/agentlinter/blob/main/packages/cli/src/upload.ts): sharing client · Transmits shareable report metadata without file contents. · `packages/cli/src/upload.ts`

### Analysis engine

Shared workspace analysis pipeline.

- [Engine API](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/index.ts): analysis facade · Coordinates normalized workspace analysis. · `src/engine/index.ts`
- [Discovery and parser](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/parser.ts): filesystem parser · Finds supported instruction files and normalizes workspace data. · `src/engine/parser.ts`
- [Workspace models](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/types.ts): TypeScript models · `src/engine/types.ts`
- [Rule registry](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/index.ts): rule orchestration · Registers composable policies and collects diagnostics. · `src/engine/rules/index.ts`
- [Security rules](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/security.ts): rule module · Checks secrets and safety concerns. · `src/engine/rules/security.ts`
- [Orchestration rules](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/rules/orchestration.ts): rule module · Checks instruction structure and agent coordination. · `src/engine/rules/orchestration.ts`
- [Scorer](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/scorer.ts): diagnostic aggregation · Computes category and overall scores. · `src/engine/scorer.ts`
- [Token budget](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/budget.ts): usage analysis · Measures instruction and token usage. · `src/engine/budget.ts`
- [Deep analyzer](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/v2/analyzer.ts): v2 analysis · Assesses cognitive load, modularity, complexity, and deeper security. · `src/engine/v2/analyzer.ts`
- [Report builder](https://github.com/seojoonkim/agentlinter/blob/main/src/engine/reporter.ts): report transformation · Converts analysis results into report-ready output. · `src/engine/reporter.ts`

### Next.js report app

Hosted report and API surface.

- [Analysis landing](https://github.com/seojoonkim/agentlinter/blob/main/src/app/analyze/page.tsx): Next.js page · `src/app/analyze/page.tsx`
- [Report viewer](https://github.com/seojoonkim/agentlinter/blob/main/src/app/r/%5Bid%5D/page.tsx): Next.js page · Loads an ID-based shared report. · `src/app/r/[id]/page.tsx`
- [Report visualization](https://github.com/seojoonkim/agentlinter/blob/main/src/app/r/%5Bid%5D/ReportClient.tsx): React client · Renders score, categories, diagnostics, and methodology tabs. · `src/app/r/[id]/ReportClient.tsx`
- [Reports API](https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/reports/route.ts): Next.js route · Creates shareable reports. · `src/app/api/reports/route.ts`
- [Report retrieval API](https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/reports/%5Bid%5D/route.ts): Next.js route · Retrieves a report by ID. · `src/app/api/reports/[id]/route.ts`
- [Badge API](https://github.com/seojoonkim/agentlinter/blob/main/src/app/api/badge/route.ts): Next.js route · Produces score SVG badges. · `src/app/api/badge/route.ts`

### External service

- [Supabase client](https://github.com/seojoonkim/agentlinter/blob/main/src/lib/supabase.ts): persistence client · Connects report APIs to report storage. · `src/lib/supabase.ts`
- **Supabase**: report storage · Stores shareable report metadata.

## Connections

- 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
