code2prompt
source code to LLM prompt converter
TLDR
Generate a prompt from source code
SYNOPSIS
code2prompt [options] path
DESCRIPTION
code2prompt transforms source code into structured prompts optimized for Large Language Models (LLMs). It recursively traverses a codebase, formats files with proper context including file paths and structure, and generates comprehensive prompts suitable for AI code assistants like Claude, GPT-4, or other LLMs.
The tool intelligently filters files based on patterns and extensions, excluding common noise like node_modules, build artifacts, and log files. Template support allows customizing the output format for different use cases such as code review, documentation generation, or architectural analysis.
Token counting helps ensure prompts fit within model context limits. The clipboard integration streamlines workflows by directly copying output for immediate use in AI chat interfaces. This is particularly valuable for providing complete codebase context when asking AI assistants for refactoring suggestions, bug analysis, or understanding unfamiliar projects.
PARAMETERS
--template name
Use a specific prompt template.--clipboard
Copy output to clipboard.--filter patterns
Include only files matching patterns.--exclude patterns
Exclude files matching patterns.--tokens
Count and display token usage.
