
Xiaolai
- 3 repo stars
- Updated May 19, 2026
- xiaolai/loc-guardian-for-claude
loc-guardian-for-claude is a Claude Code plugin that enforces configurable per-file pure lines-of-code limits using tokei counts and Opus-powered extraction plans for developers who want to prevent oversized source files
About
loc-guardian-for-claude is a Claude Code plugin from the xiaolai marketplace that enforces per-file pure LOC limits with automated optimization strategies. Install via /plugin marketplace add xiaolai/claude-plugin-marketplace and /plugin install loc-guardian@xiaolai, then run /loc-guardian:init to set limits and extraction rules in .claude/loc-guardian.local.md. The default max_pure_loc is 350 production lines excluding tests, blanks, and comments, counted by the tokei CLI across multi-language codebases. /loc-guardian:scan runs a Haiku counter pass and, when violations exist, an Opus optimizer reads over-limit files and suggests line-level extractions following your project's extraction rules. Scoped install supports user, project, or local .claude/settings.json sharing. Developers reach for loc-guardian when file size discipline matters and manual LOC audits are too slow. Prerequisites include brew install tokei on macOS and a stale-marketplace refresh via claude plugin marketplace update xiaolai if install fails.
- Counts pure LOC via tokei excluding tests, blanks, and comments
- Default 350 pure LOC per-file limit configurable in loc-guardian.local.md
- 3 slash commands: /loc-guardian:init, :scan, :scan with path or language filter
- Haiku counter + Opus optimizer only when violations are found
- Project-scope install shares config via .claude/settings.json for teams
Xiaolai by the numbers
- Data as of Jul 18, 2026 (Skillselion catalog sync)
/plugin marketplace add xiaolai/loc-guardian-for-claudeAdd your badge
Show developers this marketplace is listed on Skillselion. Paste this into your README.
| repo stars | ★ 3 |
|---|---|
| Last updated | May 19, 2026 |
| Repository | xiaolai/loc-guardian-for-claude ↗ |
How do you enforce per-file LOC limits in Claude Code?
Run /loc-guardian:scan to count pure LOC with tokei, flag files over 350 lines, and get Opus extraction plans from .claude/loc-guardian.local.md rules.
Who is it for?
Claude Code users who want automated pure-LOC enforcement with tokei counts and Opus-guided refactor extractions on violating files.
Skip if: Repositories that measure quality by total project LOC or teams unwilling to install tokei and maintain per-project extraction rules.
What you get
tokei LOC report, violation flags for over-limit files, Opus extraction suggestions, and .claude/loc-guardian.local.md configuration with max_pure_loc and extraction rules.
- LOC scan report
- violation flags
- Opus extraction plans
By the numbers
- Default per-file pure LOC limit of 350 lines
- 3 slash commands: init, scan, and language or path-filtered scan
- Two-phase workflow: Haiku counter then Opus optimizer on violations only
Recommended Marketplaces
How it compares
Pick loc-guardian when you need per-file pure LOC gates with extraction plans, not just aggregate codebase statistics.
FAQ
What does loc-guardian count as pure LOC?
loc-guardian uses tokei to measure production code lines only, excluding tests, blank lines, and comments. The default per-file ceiling is 350 pure LOC, overridable in .claude/loc-guardian.local.md via /loc-guardian:init.
How do you install loc-guardian in Claude Code?
loc-guardian installs from the Xiaolai marketplace with /plugin install loc-guardian@Xiaolai after adding Xiaolai/claude-plugin-marketplace. If install fails, run claude plugin marketplace update Xiaolai because stale marketplace clones block discovery.