Safely package local codebases into clean, LLM-optimized XML context with directory mapping and multi-model token estimation.
Project description
⚡ CodeSlimmer
Safely convert local codebases or public GitHub repos into clean, LLM-ready context with token estimation and directory mapping.
CodeSlimmer packs any code repository—whether stored on your local machine or hosted on GitHub—into a single text file structured specifically for AI models like Claude 3.5, Gemini 3.1 Pro/3.6 Flash, GPT-4o, and DeepSeek R1.
✨ Features
- 🌐 Remote GitHub URL Support: Pass any public GitHub URL (
[https://github.com/user/repo](https://github.com/user/repo)) to fetch, extract, and slim repositories directly—zerogitrequired. - 📋 Cross-Platform Clipboard Integration: Instantly copies output directly to your system clipboard (Windows, macOS, or Linux).
- 🛡️ Overwrite Safety: Inspects signature headers to ensure local files are never overwritten accidentally.
- 🌳 ASCII Directory Tree: Builds a visual project structure map at the very top of your context output.
- 🏷️ LLM-Friendly XML Output: Encloses code in clear
<file path="...">tags for max prompt accuracy. - 📊 Token Estimator: Estimates context size (~4 chars/token) and checks capacity against major models.
- 📏 Smart File Sizes: Calculates and formats physical sizes (
B,KB,MB,GB).
📦 Installation
Option A: Install via PyPI (Recommended)
Install CodeSlimmer using pip:
pip install code-slimmer
Option B: Run from Source
Clone the repository and run the script directly:
git clone [https://github.com/akasula09/codeslimmer.git](https://github.com/akasula09/codeslimmer.git)
cd codeslimmer
🚀 How to Use
1. Launch CodeSlimmer
If installed via pip:
codeslimmer
If running directly from source:
python codeslimmer.py
2. Interactive Workflows
CodeSlimmer supports two distinct input modes:
Mode 1: Local Directory Path
Enter a relative or absolute local folder path. CodeSlimmer creates ai_context.txt inside that folder and offers an optional clipboard copy. An example is below.
--- CODE SLIMMER v2.2 ---
Enter a local folder path OR a GitHub URL: my_project_folder
📄 Loaded rules from .gitignore
--- SUCCESS! ---
Packed 12 code files.
Final Context Size: 18.45 KB
💾 Added 'ai_context.txt' directly into your folder!
📊 Estimated Token Count: ~4,612 tokens
--------------------------------------------------
Which AI provider are you targeting? (gemini / claude / chatgpt / deepseek): gemini
--------------------------------------------------
🎯 Evaluated against Gemini Models:
✅ Gemini 3.1 Pro: Fits! (4,612 / 2,000,000 tokens — 0.2306% capacity)
✅ Gemini 3.6 Flash: Fits! (4,612 / 1,000,000 tokens — 0.4612% capacity)
✅ Gemini 3.5 Flash-Lite: Fits! (4,612 / 1,000,000 tokens — 0.4612% capacity)
Do you want to copy the output text directly to your clipboard as well?
Type 'y' for Yes, or press Enter to skip: y
📋 Copied full context directly to your clipboard! Ready to Ctrl+V into AI.
Mode 2: Remote GitHub Repository URL
Paste any public GitHub URL. CodeSlimmer fetches and slims the repository in a temporary workspace, estimates tokens, and prompts you to copy the result straight to your clipboard without leaving messy files behind.
--- CODE SLIMMER v2.2 ---
Enter a local folder path OR a GitHub URL: [https://github.com/akasula09/codeslimmer](https://github.com/akasula09/codeslimmer)
🌐 Fetching repository 'akasula09/codeslimmer' from GitHub...
--- SUCCESS! ---
Packed 5 code files.
Final Context Size: 12.30 KB
📊 Estimated Token Count: ~3,075 tokens
--------------------------------------------------
Which AI provider are you targeting? (gemini / claude / chatgpt / deepseek): claude
--------------------------------------------------
🎯 Evaluated against Claude Models:
✅ Claude 3.5 Sonnet / Haiku: Fits! (3,075 / 200,000 tokens — 1.5375% capacity)
✅ Claude 3 Opus: Fits! (3,075 / 200,000 tokens — 1.5375% capacity)
Do you want to copy the output text directly to your clipboard?
Type 'y' for Yes, or press Enter to skip: y
📋 Copied full context directly to your clipboard! Ready to Ctrl+V into AI.
ℹ️ Private Repositories: Unauthenticated requests to private or non-existent repositories will output:
❌ Repository does not exist or is private.
📜 Output Structure
CodeSlimmer structures the prompt context using this clean, LLM-optimized XML format:
<!-- GENERATED BY CODESLIMMER v2.2 - DO NOT EDIT MANUALLY -->
<project_structure_tree>
my_project_folder/
├── src/
│ ├── index.js
│ └── utils.js
├── .gitignore
└── package.json
</project_structure_tree>
<file path="src/index.js">
console.log("Hello World");
</file>
<file path="src/utils.js">
export function add(a, b) { return a + b; }
</file>
⚖️ License
Distributed under the PolyForm Noncommercial License 1.0.0. Free for personal, educational, research, and internal business use. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codeslimmer-2.2.0.tar.gz.
File metadata
- Download URL: codeslimmer-2.2.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad2f7c65594d8b78de96656a625095eaee31f2be30837f98fa77f0e382f2be3c
|
|
| MD5 |
d0b99c931615941fb3b0d42d18571dda
|
|
| BLAKE2b-256 |
964d5a941740731a40d1aa6838a20f18a93cf10a0ce9f3521ac7d2a6ce278975
|
Provenance
The following attestation bundles were made for codeslimmer-2.2.0.tar.gz:
Publisher:
publish.yml on akasula09/CodeSlimmer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codeslimmer-2.2.0.tar.gz -
Subject digest:
ad2f7c65594d8b78de96656a625095eaee31f2be30837f98fa77f0e382f2be3c - Sigstore transparency entry: 2329733413
- Sigstore integration time:
-
Permalink:
akasula09/CodeSlimmer@4918d44e75bfb6ecd33f091d5b451811db4c72ec -
Branch / Tag:
refs/tags/v2.2.0-alpha - Owner: https://github.com/akasula09
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4918d44e75bfb6ecd33f091d5b451811db4c72ec -
Trigger Event:
release
-
Statement type:
File details
Details for the file codeslimmer-2.2.0-py3-none-any.whl.
File metadata
- Download URL: codeslimmer-2.2.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c7daacd4daea8f96d5bc0dcfeb32c13672f79c5df7fcf100322c3a42f323d1
|
|
| MD5 |
c2e311c4099993c31752ba5e9d5d4d2b
|
|
| BLAKE2b-256 |
9285b67674fb43d5344b4201408021b3aa9f55c7184641149cc6bb4c99cbf496
|
Provenance
The following attestation bundles were made for codeslimmer-2.2.0-py3-none-any.whl:
Publisher:
publish.yml on akasula09/CodeSlimmer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codeslimmer-2.2.0-py3-none-any.whl -
Subject digest:
61c7daacd4daea8f96d5bc0dcfeb32c13672f79c5df7fcf100322c3a42f323d1 - Sigstore transparency entry: 2329733450
- Sigstore integration time:
-
Permalink:
akasula09/CodeSlimmer@4918d44e75bfb6ecd33f091d5b451811db4c72ec -
Branch / Tag:
refs/tags/v2.2.0-alpha - Owner: https://github.com/akasula09
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4918d44e75bfb6ecd33f091d5b451811db4c72ec -
Trigger Event:
release
-
Statement type: