Skip to content

34pmrndc/Scissors-sharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✂️ Scissors# - Token Pruner & Code Optimizer Agent Skill

Scissors# Logo

**Scissors#** is a public, open-source agent skill designed to help AI coding agents (such as Claude Code, Cursor, and Codex) review, refactor, and compress source code files. By programmatically stripping comments, docstrings, dead imports, and redundant spacing, this tool saves up to **50%+ of context window tokens** while providing architecture and security suggestions.

💎 Key Features

  • AST-based Python Compression: Uses Python's native Abstract Syntax Tree (ast) and ast.unparse to 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_key or password are found.
    • Bare Exception Handling: Warns about generic except: clauses.
    • Modularization: Recommends refactoring if functions or files exceed clean length limits.

🚀 How to Install and Use

1. In Claude Code (Anthropic CLI)

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-sharp

Once 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"


2. In Cursor or VS Code (.cursorrules)

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.


3. As a Standalone CLI Tool

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).


🧪 Included Reference Examples

  • 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.

About

✂️ Scissors#: An AST-based code optimizer and token pruner for Claude Code, Cursor, and Codex CLI agents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages