crystallize-cli
v0.1.0
Published
Verified code simplifier — compresses code into its crystal-clear form with PROOF that behavior is preserved
Maintainers
Readme
💎 Crystallize
Verified code simplifier — compresses code into its crystal-clear form with PROOF that behavior is preserved.
What it does
Crystallize takes messy source code and simplifies it, then proves the simplification didn't break anything by running your tests before and after.
1. SNAPSHOT — capture current behavior (tests + metrics)
2. SIMPLIFY — apply pattern-based simplifications
3. VERIFY — prove identical behavior (tests, build, metrics)
4. ACCEPT — only if all proofs passInstall
npm install -g crystallize-cliUsage
# Crystallize a single file
crystallize src/lib/managed-inference.ts
# Crystallize a directory
crystallize src/lib/
# Dry run (show what would change, don't write)
crystallize src/lib/ --dry-run
# With specific test command
crystallize src/lib/ --test-cmd "npm test"
# JSON report output
crystallize src/lib/ --format json
# Skip mutation testing (faster)
crystallize src/lib/ --skip-mutationSimplifications (v0.1)
- Remove dead imports — unused imports detected by reference scanning
- Remove console.log — debug statements (log, warn, error, debug, info)
- Remove commented-out code — heuristic detection of code in comments
- Remove empty blocks — empty try/catch, empty if bodies
- Simplify boolean returns —
if (x) return true; else return false;→return x; - Remove redundant types —
const x: string = "hello"→const x = "hello"
Verification
After simplification, Crystallize verifies:
- Tests — all tests still pass, no test count decrease
- Build — project still compiles
- Lines — line count decreased (or unchanged)
- Complexity — nesting depth didn't increase
If ANY check fails → changes are automatically reverted.
Design Principles
- Tests are proof — Crystallize never modifies test files
- Auto-revert on failure — git stash checkpoint before changes
- Pattern-based — regex/line analysis, no heavy AST parser (v0.1)
- Minimal dependencies — commander, chalk, diff
License
MIT
