optimize-project
npx machina-cli add skill Roberdan/MyConvergio/optimize-project --openclawOptimize Project Skill
User-invocable workflow to audit, fix, and bootstrap token-efficient project instructions.
Modes
--audit: analysis only, no file changes--fix: apply safe auto-fixes after audit--setup: bootstrap optimize-project baseline for new repositories
When to Use
- Existing repository has verbose instruction/docs churn
- CLAUDE.md and agent files have drift or redundancy
- Comments are consuming too many tokens
- New repository needs compact defaults from day one
Workflow
Step 1: Detect project type and language
Collect project signals from root:
- Node/TS:
package.json,tsconfig.json - Python:
pyproject.toml,requirements.txt - Go:
go.mod - Rust:
Cargo.toml - Bash-heavy:
scripts/*.sh, hooks, no language manifest
Report detected stack, dominant language, test command, and docs/instruction locations.
Step 2: Run project audit script
Run the standard audit first (machine-first, JSON output):
~/.claude/scripts/project-audit.sh --project-root . --json
Use this output as baseline counts for debt, risk, and comment-density flags.
Step 3: AI analysis (token efficiency + quality)
Analyze audit output plus repository files for:
- CLAUDE.md quality
- conflicting rules
- duplicated sections
- verbose prose where compact tables/checklists are better
- Agent file redundancy
- duplicated guidance across
AGENTS.md,CLAUDE.md, skill files - repeated workflow text better centralized in one reference file
- duplicated guidance across
- Comment token waste
- comments that restate obvious code behavior
- long explanatory blocks with no decision context
- stale comments that no longer match code
Comment-density severity:
- P2 if comment density is
> 10% - P1 if comment density is
> 20%
Step 4: Generate optimization report
Return a structured report:
## Optimize Project Report: {project}
### Mode
{--audit|--fix|--setup}
### Detection
- Type: {type}
- Language: {language}
- Framework: {framework}
### Audit Summary
| Severity | Count |
|----------|-------|
| P1 | {n} |
| P2 | {n} |
| P3 | {n} |
### AI Findings
| # | Severity | Area | File | Issue | Suggested Action |
|---|----------|------|------|-------|------------------|
### Token Savings Estimate
- Estimated current instruction/comment tokens: {current}
- Estimated optimized tokens: {optimized}
- Estimated savings: {saved} ({percent}%)
Savings estimate should separate:
- instruction/documentation compaction
- redundant agent content removal
- comment cleanup impact
Step 5: Apply safe auto-fixes (--fix mode)
Only safe, low-risk fixes are allowed automatically:
.gitignorehygiene:- add missing common local/runtime artifacts
- avoid removing existing ignore patterns without evidence
- Comment cleanup:
- remove trivial comments that restate obvious code
- keep comments that explain why, invariants, or non-obvious constraints
- never change executable logic during cleanup
After fixes, rerun:
~/.claude/scripts/project-audit.sh --project-root . --json
Report before/after deltas and updated token-savings estimate.
Step 6: Setup mode for new projects (--setup)
Bootstrap optimize-project baseline:
- Detect stack and choose matching minimal templates
- Create compact
CLAUDE.mdbaseline with no duplicated policy blocks - Add starter
AGENTS.md+ skill references with clear ownership boundaries - Add/update
.gitignorewith language-appropriate defaults - Run
project-audit.sh --jsonand return initial health report
--setup must prefer concise templates and avoid adding verbose boilerplate.
Guardrails
--auditnever writes files--fixwrites only safe auto-fixes listed above--setupcreates baseline files but does not overwrite user-authored docs without explicit diff review- All outputs must be deterministic and machine-readable where possible
References
- Pattern baseline:
~/.claude/skills/review-pr/SKILL.md - Audit script:
~/.claude/scripts/project-audit.sh - Hardening context:
~/.claude/skills/hardening/SKILL.md
Source
git clone https://github.com/Roberdan/MyConvergio/blob/master/.claude/skills/optimize-project/SKILL.mdView on GitHub Overview
Optimize project instructions and agent setup to reduce token usage while preserving signal. It audits repository docs, agent files, and comments, then can apply safe auto-fixes or bootstrap a compact baseline for new repos.
How This Skill Works
Runs a mode-based workflow: detect project type from root files, run a JSON-output audit, analyze CLAUDE.md quality, agent-file redundancy, and comment-waste, then generate an optimization report. In --fix mode it applies safe changes like .gitignore hygiene and targeted comment cleanup.
When to Use It
- Existing repo has verbose instructions causing token bloat
- CLAUDE.md or AGENTS.md drift or redundancy
- Comment density high, wasting tokens
- New repo needs compact defaults from day one
- You want a safe baseline for token-efficient setup
Quick Start
- Step 1: Run an audit to generate a JSON baseline (example: audit script or optimize-project audit mode)
- Step 2: Review the AI findings and the optimization report for opportunities
- Step 3: Run safe auto-fixes with --fix or bootstrap a baseline with --setup for a new repo
Best Practices
- Run --audit first to establish baseline
- Limit auto-fixes to trivial, non-executable changes
- Consolidate duplicated guidance into a single reference
- Target long prose and replace with concise tables and checklists
- Use --setup to bootstrap concise defaults for new projects
Example Use Cases
- Audit an existing repo with verbose CLAUDE.md to reveal token waste
- Identify duplicated guidance across CLAUDE.md and AGENTS.md
- Replace long comments with decision-context notes in codebase
- Bootstrap a new repo with concise CLAUDE.md and starter AGENTS.md
- Reduce comment density from high to balanced for efficient signaling