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! 🚀
Metadata
Release files for codehammer 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| codehammer-0.0.1.tar.gz | 13.9 kB | Without provenance | Details for codehammer-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codehammer-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for codehammer-0.0.1-py3-none-any.whl |
Total release size: 30.1 kB
Release files / codehammer-0.0.1.tar.gz
| Download URL | codehammer-0.0.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36656128d9cfd1904085534df49f5b0f22b0505c08771fe5e25856eb0192c6da
|
|
BLAKE2b-256 checksum How to use checksums |
769e6c4e6eeea6740a8a97603b7677c9b9a48824cd199baa7c60e259b1fc889b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / codehammer-0.0.1-py3-none-any.whl
| Download URL | codehammer-0.0.1-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b7620518c5cfc119d8de1f4457d941e8ce6879dccfd02b19e861f2bafce368a
|
|
BLAKE2b-256 checksum How to use checksums |
ec86ee82f9412fe9b202f456c316e527393d96b956792e705cd799535cf72696
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Security for codehammer 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.