opencode-lgtm
v0.0.1
Published
A high-quality OpenCode plugin for senior engineers, focused on design and code review.
Readme
LGTM
"Review as if you have to maintain it forever."
LGTM (opencode-lgtm) is an OpenCode plugin designed for experienced engineers. It focuses on high-level architectural design, code quality, and rigorous code reviews.
Vision
Unlike generic coding assistants that focus on writing code quickly, LGTM focuses on writing code correctly. It acts as a digital Staff Engineer or Maintainer.
Key Features
- Architectural Guardrails: Analyzes changes against project-specific design patterns.
- Deep Code Review: Focuses on edge cases, security, and maintainability rather than just syntax.
- Maintainer Persona: Provides rationales for suggestions, fostering a culture of mentorship.
- Review-Only Mode: By default, it suggests and explains rather than blindly editing files.
Philosophy
- Quality over Speed: Better to have no code than bad code.
- Explicit over Implicit: Use clear types and patterns.
- OSS Spirit: Open, collaborative, and opinionated.
Development
- Run
bun run checkbefore opening a PR. specs/is a git submodule; keep it pinned to the intendedlgtm-specscommit.
Agents
- Primary entrypoint:
@review(LGTM Review Lead). roles/*agents (e.g.roles/planner,roles/reviewer/logic) are internal subagents used by the lead viatask.- If you manually select a
roles/*agent (e.g.@roles/planner), LGTM will warn and you should switch back to@review.
Tools
lgtm status: shows detected language and whether config loaded.lgtm clean_cache: clears LGTM cache.lgtm gen_policy: creates/updates.lgtm/policy.mdfor the current repo.- On update, writes a backup to
.lgtm/policy.md.bak. - Add repo-specific guidance under "Local Notes (Preserved)" (kept on reruns).
- On update, writes a backup to
Debugging
- Inspect rendered prompts/models:
opencode debug agent reviewopencode debug agent roles/explorer
- Inspect what was sent in a run:
- JSONL logs:
~/.local/state/opencode/lgtm/logs/*.jsonl(orXDG_STATE_HOME/opencode/lgtm/logs) - Export a session:
opencode export <sessionID>
- JSONL logs:
Default Config
- The plugin ships a default config template at
config/default.json. - Full config reference:
config/README.md. - On startup, LGTM loads this bundled default first, then overlays user config from
~/.config/opencode/lgtm/config.json(orXDG_CONFIG_HOME/opencode/lgtm/config.json). - To customize locally, copy and edit:
cp config/default.json ~/.config/opencode/lgtm/config.json
- User config is treated as the source of truth for explicitly configured capabilities. By default (
skip_model_validation: false), startup fails fast when a configured capability cannot resolve to any usable model.
Interactive Model Setup
- Run
bun run setup:modelsto launch a terminal wizard. - The wizard reads available provider/model IDs from OpenCode config (
~/.config/opencode/config.jsonorXDG_CONFIG_HOME/opencode/config.json) and writes LGTM config to~/.config/opencode/lgtm/config.json. - If strict validation fails, rerun
bun run setup:modelsor manually updatemodels.capabilitiesso each configured capability has at least one usable model.
Config Parameters
- Configure runtime policy in
defaultsinside~/.config/opencode/lgtm/config.json. defaults.review_bash_policy- Default:
relaxed strict: enforce single-command, read-onlygit/ghusage in@Reviewworkflows.
- Default:
defaults.allow_general_fallback- Default:
false trueallows capability resolution fallback togeneralwhen direct capability candidates are unavailable.- Security posture: keep disabled unless you explicitly want resilience over strict capability isolation.
- Default:
defaults.debug_logging- Default:
false trueenables LGTM debug JSONL logging.
- Default:
Debug Payload Guards
- LGTM debug logs record full prompts/outputs for traceability.
- Some upstream tool outputs may still be truncated before LGTM sees them (e.g. large command output payloads).
