Claude-skill-registry auditing-libraries
This skill should be used when the user asks to "audit libraries", "check library conventions", "validate lib structure", "find convention violations", "review library organization", or wants to verify that existing libraries follow the _.ts/__.ts namespace pattern correctly. Identifies and reports violations.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/auditing-libraries" ~/.claude/skills/majiayu000-claude-skill-registry-auditing-libraries && rm -rf "$T"
manifest:
skills/data/auditing-libraries/SKILL.mdsource content
Auditing Libraries
Analyze existing libraries for convention violations and report issues.
CRITICAL
Read Conventions Before Auditing
The authoritative convention documents are:
— Core~/.claude/docs/conventions/namespace-module.md
/_.ts
pattern__.ts
— Local library context (~/.claude/docs/conventions/library-local.md
)src/lib/
— Package-level context~/.claude/docs/conventions/library-package.md
Read these before auditing to understand the full rules.
Operations
Audit Single Library
Check a specific library for violations.
Steps:
- Identify library type (local lib, package lib)
- Check file structure matches expected pattern
- Validate
content_.ts - Validate
content (if exists)__.ts - Check import patterns in code modules
- Verify test file imports
- Report all violations found
Audit All Libraries
Scan project for all libraries and check each.
Steps:
- Find all directories containing
files_.ts - Categorize each (local lib at
, package lib atsrc/lib/*
)src/* - Audit each library individually
- Summarize violations by category
Fix Violations
After auditing, fix identified issues.
Steps:
- Present violations to user
- Propose fixes for each
- Apply fixes with user approval
- Re-audit to confirm resolution
Violation Categories
Structure Violations
| Violation | Description | Fix |
|---|---|---|
Missing | Library has no namespace module | Create with correct export |
Missing | Multiple impl files but no barrel | Create with re-exports |
Extra | Single impl file with barrel | Remove , update |
| Wrong location | Library not in | Move to correct location |
Namespace Module (_.ts
) Violations
_.ts| Violation | Description | Fix |
|---|---|---|
| Wrong export target | Points to wrong file | Fix export path |
| Has imports | Contains import statements | Remove imports |
| Wrong namespace name | Doesn't match directory | Fix namespace name |
| Missing barrel reference | Has but exports from impl | Change to |
Barrel Module (__.ts
) Violations
__.ts| Violation | Description | Fix |
|---|---|---|
Imports from | Circular dependency | Remove import |
| Value imports | Has not re-export | Convert to |
| External imports | Imports from outside library | Move to code module |
| Parent imports | Imports from | Remove or restructure |
Import Pattern Violations
| Violation | Description | Fix |
|---|---|---|
| Destructured namespace | | Use then |
| Self namespace import | Code imports own | Use relative imports |
| Self barrel import | Code imports own | Use relative imports |
| Relative cross-lib | | Use |
Test Violations
| Violation | Description | Fix |
|---|---|---|
| Wrong import | Test imports from impl file | Import from |
| Destructured | Test destructures namespace | Use namespace directly |
| Missing fixture namespace | Fixture doesn't export | Add |
Audit Checklist
## Library: <name> ### Structure * [ ] Located at correct path (src/lib/<name>/ or src/<name>/) * [ ] Has _.ts namespace module * [ ] Has __.ts barrel (if multiple impl files) * [ ] No __.ts (if single impl file) ### Namespace Module (_.ts) * [ ] Correct export pattern * [ ] Namespace name matches directory (PascalCase) * [ ] No import statements * [ ] Points to __.ts (if exists) or impl file ### Barrel Module (__.ts) - if exists * [ ] Only contains re-exports * [ ] No imports from _.ts * [ ] No external package imports * [ ] All exports from local files ### Code Modules * [ ] No imports from own _.ts * [ ] No imports from own __.ts * [ ] Cross-lib imports use #<name> * [ ] Sibling imports use relative paths ### Tests (_.test.ts) * [ ] Imports from ./_.js only * [ ] Uses namespace, no destructuring * [ ] No top-level describe wrapping all tests ### Config * [ ] package.json has imports entry * [ ] tsconfig.json has paths entry
Examples
Violation Report Format
Library: src/lib/parser/ VIOLATIONS FOUND: 3 1. [NAMESPACE] _.ts has wrong export Current: export * from './parser.js' Expected: export * as Parser from './__.js' Reason: __.ts exists, so _.ts must export namespace from barrel 2. [IMPORT] tokenizer.ts imports from own namespace Line 3: import { Parser } from './_.js' Fix: Use relative import: import { helper } from './helper.js' 3. [TEST] _.test.ts destructures namespace Line 1: import { tokenize, lex } from './_.js' Fix: import { Parser } from './_.js' then use Parser.tokenize
Notes
- Run
command for automated fixing/fix-conventions - Some violations require architectural decisions (restructuring)
- Package-level libraries have different path expectations