A tool to combine code files into a single prompt
Project description
CodeHammer: A Code Processing Toolkit
Overview
CodeHammer is a lightweight tool designed to combine, analyze, and manage code files efficiently. It helps developers extract and format relevant code snippets for AI-assisted development, debugging, and modification.
Features
- File and Directory Inspection: Retrieve file contents, list directory structures, and analyze project organization.
- Automated Code Processing: Identify and manipulate specific code files based on extensions.
- Code Modification: Write and update files programmatically.
- Cleanup and Maintenance: Remove unnecessary files from results folders.
- Seamless CLI Integration: Designed to work with command-line tools for easy access.
Installation
To install CodeHammer, run:
pip install codehammer
Available CLI Commands
CodeHammer provides a command-line interface (CLI) to process and manage code files.
🔍 1. tree
Retrieve the structure of a directory
Returns a list of all files in a specified directory, excluding.gitignore-listed files.
Usage
code-hammer tree --folder src --base-dir .
Example Output
src/main.py
src/utils/helpers.py
src/config/settings.json
📄 2. file
Read the content of a specific file
Retrieves the contents of a file for analysis or processing.
Usage
code-hammer file --file src/main.py --base-dir .
Example Output
def main():
print("Hello, world!")
📂 3. files
List all files in a specific folder
Provides a JSON list of files within the specified folder.
Usage
code-hammer files --folder src --base-dir .
Example Output
{
"main.py": "def main():\n print('Hello, world!')",
"config.json": "{'debug': true, 'version': '1.0'}"
}
📁 4. files_recursive
Retrieve all files in a folder and its subdirectories
Useful for analyzing an entire project structure.
Usage
code-hammer files_recursive --folder src --base-dir .
Example Output
{
"src/main.py": "def main():\n print('Hello, world!')",
"src/utils/helpers.py": "def helper():\n return 'Helper function'"
}
🔎 5. find_files
Find all files matching specific extensions in the base directory
Helpful for searching for specific types of files, such as Python scripts or Markdown documentation.
Usage
code-hammer combine --extensions py md --output-file output.txt --base-dir .
Example Output
Merged files: ['src/main.py', 'docs/readme.md']
✍️ 6. write
Write or modify a file
Creates or modifies a file inside the.resultfolder.
Usage
code-hammer write --file output.txt --content "New content for the file" --base-dir .
Example Output
File written successfully: .result/output.txt
🧹 7. clean_result
Remove unnecessary files from the
.resultfolder
Ensures that old files don’t clutter the workspace.
Usage
code-hammer clean_result --exclude-clean output.txt --base-dir .
Example Output
Cleaned .result folder. Removed files: ['output.txt']
🛠 8. combine
Merge multiple files into a single output file
Key feature for creating context-rich inputs for LLMs.
Usage
code-hammer combine --extensions py md --output-file combined.txt --base-dir .
Example Output
Merged files: ['src/main.py', 'docs/readme.md']
Using CodeHammer in Python
CodeHammer provides a Python API for programmatic access.
Example Usage
from code_hammer.core.main import CodeHammer
# Initialize CodeHammer
hammer = CodeHammer(base_dir=".")
# Get directory structure
print(hammer.get_directory_tree("."))
# Read file content
print(hammer.get_file_content("src/main.py"))
# Combine Python files into a single output file
hammer.forge_prompt(["py"])
Conclusion
CodeHammer is a simple yet powerful tool for managing and processing code files. It is designed to work efficiently with LLM-powered assistants, automated code analyzers, and developer workflows.
🚀 Get started with CodeHammer today! 🚀
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 codehammer-0.0.1.tar.gz.
File metadata
- Download URL: codehammer-0.0.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36656128d9cfd1904085534df49f5b0f22b0505c08771fe5e25856eb0192c6da
|
|
| MD5 |
7f76fca9c409c9ace79f4e3277d3e91b
|
|
| BLAKE2b-256 |
769e6c4e6eeea6740a8a97603b7677c9b9a48824cd199baa7c60e259b1fc889b
|
File details
Details for the file codehammer-0.0.1-py3-none-any.whl.
File metadata
- Download URL: codehammer-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b7620518c5cfc119d8de1f4457d941e8ce6879dccfd02b19e861f2bafce368a
|
|
| MD5 |
11269671be215ec48620095dae989dce
|
|
| BLAKE2b-256 |
ec86ee82f9412fe9b202f456c316e527393d96b956792e705cd799535cf72696
|