-
AST-based Python Compression: Uses Python's native Abstract Syntax Tree (
ast) andast.unparseto safely strip comments, function docstrings, class docstrings, and module docstrings. It keeps syntax 100% correct and formats output spacing cleanly. -
C-Style Comments Stripper: Minifies JS, TS, JSX, TSX, and CSS comments (
//and/* */). - Automated Token Metrics: Calculates and prints original size, optimized size, and exact token savings.
-
Static Code Quality Audits: Automatically scans the code for:
-
Complexity Smells: Identifies nested loops with
$O(N^2)$ complexity. -
Hardcoded Credentials: Warns if secrets like
api_keyorpasswordare found. -
Bare Exception Handling: Warns about generic
except:clauses. - Modularization: Recommends refactoring if functions or files exceed clean length limits.
-
Complexity Smells: Identifies nested loops with
To enable this skill in Claude Code, clone this repository directly into the .agents/skills/scissors-sharp directory of your active workspace:
git clone https://github.com/34pmrndc/Scissors-sharp.git .agents/skills/scissors-sharpOnce cloned, Claude Code will automatically discover the skill. You can trigger it by asking in your CLI chat:
"Usa la skill Scissors# para optimizar y reducir los tokens de este archivo: ruta/al/archivo.py"
Copy the contents of the SKILL.md file and paste it directly into your .cursorrules file at the root of your project. Claude 3.5 Sonnet inside Cursor will immediately inherit the guidelines to write token-efficient code.
You can also run the optimization script directly from your terminal using Python:
# Print optimization report and suggestions (does not modify the file)
python scripts/optimize.py --file path/to/your_code.py
# Optimize, strip comments/docstrings, and overwrite the file directly
python scripts/optimize.py --file path/to/your_code.py --overwrite(Note: On Windows, the script reconfigures stdout to UTF-8 so emojis print cleanly in PowerShell or cmd).
- examples/original.py: A sample Python file containing duplicate code, bare exceptions, hardcoded credentials, and heavy docstrings.
- examples/optimized.py: The resulting pruned file showing 53.9% token savings generated by
optimize.py.
