agentsclimarketplace

Loc optimization

Skill xiaolai/loc-guardian-for-claude/skills/loc-optimization

Use when analyzing files that exceed pure LOC limits, or when suggesting code optimization opportunities to reduce file size.From its SKILL.md

Install
npx -y skills add xiaolai/loc-guardian-for-claude --skill loc-optimization

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

1.7 KB, as published. Nobody here has run it

LOC Optimization Knowledge

Config File: .claude/loc-guardian.local.md

The /loc-guardian:init command creates this file. Format:

---
max_pure_loc: 350
---

Followed by a markdown body containing the project's extraction rules — user-defined, project-specific patterns for how to split oversized files. Example format:

## Extraction Rules

- [What to extract] → `[target file naming convention]`
- [What to extract] → `[target file naming convention]`

The actual rules vary by project and are written by the user during init. The agent MUST read this file and use the user's extraction rules verbatim when making suggestions. If the file has no extraction rules in the body, fall back to generic patterns (see below).

Generic Optimization Patterns (Fallback)

Use these ONLY when the project has no extraction rules configured:

Eliminate Duplication

  • Repeated patterns that differ only in data → data-driven approach
  • Copy-pasted blocks with slight variations → parameterized function

Simplify Conditionals

  • Nested if/else → early returns or guard clauses
  • Long switch → lookup object/map
  • Repeated null checks → optional chaining or nullish coalescing

Leverage Framework Features

  • Manual DOM manipulation → declarative framework patterns
  • Hand-rolled state management → built-in hooks/stores
  • Imperative iteration → declarative array methods

Remove Dead Code

  • Unused imports, variables, functions
  • Commented-out code blocks
  • Feature flags for features that shipped long ago

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.