Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By xiaolaiv0.4.2ISCIn 2 marketplaces
Enforce per-file pure LOC limits with automated optimization strategies — counts, flags violations, and provides opus-powered extraction plans
You run one by typing its /name in Claude Code.
No risk signals detected
Nothing flagged in this plugin's hooks, MCP servers or commands. Other components are not analyzed.
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
2 marketplaces, most starred first
loc, lines-of-code, metrics, tokei, code-quality, file-size-limits
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Public GitHub repos that commit this plugin as enabled in their Claude Code settings
Enforce per-file pure LOC limits with automated optimization strategies.
| Command | Description |
|---|---|
/loc-guardian:init | Configure LOC limit and extraction rules for your project |
/loc-guardian:scan | Count LOC, check limits, get optimization strategies |
/loc-guardian:scan python | Count only Python files |
/loc-guardian:scan src/ | Count only files under src/ |
Part of the xiaolai plugin marketplace.
Node.js 18+ — the counting and formatting run in a small dependency-free script, so the
numbers come from tested code rather than from a model's arithmetic. Check with node --version.
(Claude Code's native builds do not bundle Node, so this may need installing separately.)
And tokei:
| Platform | Command |
|---|---|
| macOS / Linux (Homebrew) | brew install tokei |
| Any platform with Rust | cargo install tokei |
| Debian / Ubuntu | apt install tokei |
| Fedora | dnf install tokei |
| Arch | pacman -S tokei |
| Windows | scoop install tokei |
Add the marketplace (once):
/plugin marketplace add xiaolai/claude-plugin-marketplace
Then install:
/plugin install loc-guardian@xiaolai
Install fails with "Plugin not found in marketplace 'xiaolai'"? Your local marketplace clone is stale. Run
claude plugin marketplace update xiaolaiand retry —plugin installdoes not auto-refresh.
| Scope | Command | Effect |
|---|---|---|
| User (default) | /plugin install loc-guardian@xiaolai | Available in all your projects |
| Project | /plugin install loc-guardian@xiaolai --scope project | Shared with team via .claude/settings.json |
| Local | /plugin install loc-guardian@xiaolai --scope local | Only you, only this repo |
Run /loc-guardian:init in your project to set your LOC limit and extraction rules
The same repository ships a Codex layout (.codex-plugin/ and codex/):
codex plugin marketplace add xiaolai/claude-plugin-marketplace
codex plugin add loc-guardian@xiaolai
In a Codex session, run $loc-guardian-init, then $loc-guardian-scan. Both tools run the
same scripts/reduce-loc.mjs and share .claude/loc-guardian.local.md. Codex runs every step
on the session model (no Haiku/Opus split); see codex/AGENTS.md for the differences.
scripts/reduce-loc.mjs — computes every metric and formats every table. Counting lines
is arithmetic, so it lives in tested code (node scripts/reduce-loc.test.mjs).The scan is a plain shell pipeline; no model is needed to enforce the limit:
D=$(mktemp -d) && trap 'rm -rf "$D"' EXIT
tokei . -o json > "$D/all.json"
tokei . --exclude tests --exclude __tests__ --exclude __fixtures__ -o json > "$D/prod.json"
node scripts/reduce-loc.mjs --all "$D/all.json" --prod "$D/prod.json" --limit 350 --check
| Exit | Meaning |
|---|---|
0 | scan valid, nothing over the limit |
1 | the scan did not happen (bad arguments, unreadable or malformed input) |
2 | scan valid, at least one file over the limit — only with --check |
1 and 2 are deliberately distinct: a broken scan must never look like a clean one.
/loc-guardian:init creates .claude/loc-guardian.local.md in your project:
---
max_pure_loc: 350
---
## Extraction Rules
- [What to extract] → `[target file pattern]`
- [What to extract] → `[target file pattern]`
The extraction rules are yours — tailored to your language, framework, and conventions.
ISC
npx claudepluginhub xiaolai/loc-guardian-for-claude --plugin loc-guardianBuilt from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
Plugins from other owners that cover similar ground