How hexmostech/git-lrc works
Purpose and Entry Points
git-lrc is a Go CLI that enforces AI-assisted code review at Git commit time, plus manual review, setup, connector management, hook management, and self-update commands. The executable starts at main.go; command registration/dispatch is centered in cmd/app.go. It is invoked as lrc or git lrc, and Git hooks route commit events into the CLI.
Commit Hook Enforcement
Global/per-repository Git hook installation and lifecycle management form the enforcement boundary. Shell hook templates invoke a dispatcher, which calls the binary before a commit proceeds; repository enablement can override global behavior.
• hooks/managed.go
• hooks/operations.go
• hooks/dispatcher.sh
The pre-commit path launches the review/vouch/skip decision flow; commit-message handling appends the review attestation to Git history.
• hooks/pre-commit.sh
• hooks/prepare-commit-msg.sh
• internal/appcore/attestation_flow.go
Review Orchestration and State
internal/appcore is the application service layer coordinating repository inspection, diff selection, review launch, user decisions, and final commit continuation/abort. It separates command/UI concerns from review protocol, persistence, and Git-facing operations.
• internal/appcore/review_runtime.go
• internal/appcore/repository_context.go
• internal/appcore/review_state.go
Review modes accept staged diffs, commits, or ranges. Review iterations and final-diff coverage are computed and attached as ran, vouched, or skipped attestations.
• attestation/coverage_compute.go
• attestation/diffparse.go
• attestation/db.go
Local Review Service and Browser UI
A local HTTP server exposes review data and actions, then opens a browser-based diff viewer. The backend contract/model layers isolate review responses and persistence from rendering; static HTML/JS supplies the issue navigator, inline comments, event log, decision controls, and summary UI.
• internal/reviewapi/helpers.go
• internal/reviewdb/service.go
• internal/reviewhtml/template.go
• internal/staticserve/static_serve.go
• internal/staticserve/static/index.html
This is a local browser UI, not a hosted web application; it communicates with the CLI-hosted local service.
Remote Services and AI Connectors
The network layer encapsulates HTTP calls for review execution, setup/authentication, UI connector operations, and update manifests. LiveReview coordinates reviews/account functions, while the selected BYOK provider supplies model inference. Supported providers include Gemini, OpenAI, Claude/Anthropic-compatible endpoints, DeepSeek, OpenRouter, and Atlas Cloud.
• network/review_client.go
• network/setup_client.go
• network/ui_client.go
• config/ai_connectors.go
Connector configuration is managed through a separate local UI flow and persisted locally.
• internal/appui/ui_connectors.go
• internal/appui/ui_connectors_handlers.go
• internal/staticserve/static/ui-connectors.html
Setup, Authentication, and Local Persistence
Guided setup provisions credentials and deployment configuration, using a local login/callback server to complete browser-based authentication. App state, connector config, review sessions, hook files, and SQLite-backed review/attestation records are mediated through storage, keeping filesystem/database I/O outside orchestration logic.
• setup/login_server.go
• setup/provision.go
• storage/config_io.go
• storage/sqlite_query_io.go
• storage/review_sessions_queries.go
Repository Policy Context and Distribution
Per-repo .lrc rules and ignore patterns are loaded, validated, and assembled into bounded reviewer context; ignored paths are excluded before external review submission. Claude Code integration installs/maintains complementary hooks and assets. Binary updates use signed/checksummed manifest-oriented update logic.
• internal/lrcrules/lrcrules.go
• internal/lrcrules/ignore.go
• internal/appcore/claude_hooks_management.go
• internal/selfupdate/self_update.go
Main entry points: review_runtime.go Review orchestration · app.go Command dispatch · config_io.go Local storage I/O · dispatcher.sh Hook dispatcher
Components 21
CLI & Git Enforcement
- CLI entrypoint
main.go - Command dispatch
cmd/app.go - Hook lifecycle · Installs and manages global or repository hook behavior.
hooks/managed.go - Hook dispatcher
hooks/dispatcher.sh - Pre-commit review gate
hooks/pre-commit.sh - Commit attestation hook
hooks/prepare-commit-msg.sh
Review Runtime
- Review orchestration · Selects diffs, launches review, and continues or aborts commits.
internal/appcore/review_runtime.go - Repository context
internal/appcore/repository_context.go - Review state
internal/appcore/review_state.go - Attestation decisions · Records ran, vouched, or skipped review outcomes.
internal/appcore/attestation_flow.go - Repository policy · Filters ignored paths and bounds reviewer context.
internal/lrcrules/lrcrules.go - Coverage & attestations
attestation/coverage_compute.go
Local UI & Persistence
- Local review API
internal/reviewapi/helpers.go - Browser diff viewer · Displays diffs, comments, events, and decision controls.
internal/staticserve/static/index.html - Review persistence · Stores review sessions and attestation records.
internal/reviewdb/service.go - Local storage I/O · Mediates config, sessions, files, and SQLite access.
storage/config_io.go - Setup & browser login
setup/login_server.go - Connector management UI
internal/appui/ui_connectors.go
Remote Services
- LiveReview service · Executes reviews and account operations.
network/review_client.go - BYOK model providers · Selects Gemini, OpenAI, Anthropic-compatible, DeepSeek, OpenRouter, or Atlas Cloud.
config/ai_connectors.go - Signed self-update
internal/selfupdate/self_update.go
Connections 27
- CLI entrypoint → Command dispatch: starts
- Command dispatch → Hook lifecycle: manages hooks
- Hook lifecycle → Hook dispatcher: installs
- Hook dispatcher → Pre-commit review gate: routes pre-commit
- Hook dispatcher → Commit attestation hook: routes commit message
- Pre-commit review gate → Review orchestration: enforces review
- Command dispatch → Review orchestration: manual review
- Review orchestration → Repository context: inspects repository
- Repository context → Repository policy: loads rules
- Repository policy → Review orchestration: filtered context
- Review orchestration → Review state: tracks session
- Review orchestration → LiveReview service: submits review
- LiveReview service → BYOK model providers: uses selected provider
- Review orchestration → Local review API: hosts local review
- Local review API → Browser diff viewer: serves data and actions
- Local review API → Review persistence: reads and writes
- Review state → Local storage I/O: persists sessions
- Review persistence → Local storage I/O: SQLite I/O
- Review orchestration → Coverage & attestations: computes coverage
- Coverage & attestations → Attestation decisions: attaches outcome
- Attestation decisions → Commit attestation hook: appends attestation
- Command dispatch → Setup & browser login: runs setup
- Setup & browser login → Local storage I/O: stores credentials
- Command dispatch → Connector management UI: manages connectors
- Connector management UI → BYOK model providers: configures
- Connector management UI → Local storage I/O: persists configuration
- Command dispatch → Signed self-update: updates binary