aicoolies logo
code2prompt logo
code2prompt logo

code2prompt

CLI tool to convert codebases into LLM-ready prompts

open sourceupdated Jul 7, 2026

code2prompt is a Rust CLI that converts entire codebases into structured prompts optimized for LLM context windows. It intelligently filters files using gitignore patterns, respects token budgets, generates directory tree visualizations, and supports custom Handlebars templates for output formatting. The tool addresses the core challenge of feeding large codebases to AI coding assistants by producing clean, organized context that maximizes the value of limited token budgets.

code2prompt solves one of the most practical challenges in AI-assisted development: getting relevant codebase context into an LLM prompt without exceeding token limits or drowning the model in irrelevant files. The CLI traverses a project directory, respects gitignore rules and custom exclusion patterns, and assembles the selected files into a structured prompt with directory tree visualization, file contents, and metadata. Token counting against configurable limits helps developers stay within context window budgets for their target model.

The Handlebars template system allows customizing the output format for different use cases. Developers can create templates that emphasize architecture documentation, code review context, bug investigation, or refactoring analysis, each surfacing different aspects of the codebase. Built-in templates cover common scenarios, while the extensible template system accommodates specialized workflows. The Rust implementation ensures fast traversal of large repositories without the startup overhead of interpreted languages.

With over 7,300 GitHub stars and 300+ forks, code2prompt has become a standard tool in the AI coding workflow alongside tools like Repomix. The MIT license enables unrestricted use, and the single-binary distribution means no runtime dependencies to manage. The tool integrates naturally into command pipelines, accepting input from standard repository structures and outputting formatted text that can be piped directly to clipboard managers or LLM API calls.

Pricing

Free and open source under MIT License

Platforms

CLI on macOS, Linux, Windows

Categories

Tags

Use Cases

GStack logo

GStack

Virtual engineering team as Claude Code skills by YC CEO Garry Tan

GStack transforms Claude Code into a structured virtual engineering team through 23 opinionated slash command skills created by Y Combinator CEO Garry Tan. It assigns specialist roles including CEO product review, engineering manager architecture oversight, designer visual audit, QA lead with real browser testing, and release engineer deployment. Each skill enforces focused workflows with clear decision principles for running parallel coding sessions.

Open Source
Everything Claude Code logo

Everything Claude Code

Agent harness performance system with 30+ agents and 136 skills

Everything Claude Code is a comprehensive agent harness performance optimization system providing 30 specialized agents, 136 skills, 60 commands, and automated hook workflows for AI-assisted development. Born from an Anthropic hackathon winner and evolved over 10+ months of intensive daily use, it works across Claude Code, Codex, Cursor, and OpenCode with built-in security scanning via AgentShield, continuous learning, and research-first development patterns.

Open Source
Embedder logo

Embedder

AI coding agent for embedded systems and firmware engineering

Embedder is a specialized AI coding agent for firmware and embedded systems development. It supports 400+ MCU variants including STM32 and ESP32, parses hardware datasheets to understand register maps and pin configurations, and verifies generated code by interacting with physical boards via serial console. YC S25 participant currently in beta.

api-usage-based

Related Tools

computed discovery: shared active categories · kept separate from editor-verified Alternatives

Grok logo

Grok Build

Top Pick

xAI's terminal coding agent with parallel subagents and worktree-aware automation

Grok Build is xAI's terminal-first coding agent for planning, editing, testing, and reviewing code from a local CLI. The early beta exposes subagent controls, worktree mode, headless JSON output, best-of-N parallel attempts, sandbox profiles, and experimental memory. It fits developers comparing Claude Code, Codex, and Gemini CLI for local agentic workflows with deeper parallel execution.

paid
Ghostty logo

Ghostty

Top Pick

Fast, native terminal emulator

GPU-accelerated terminal emulator written in Zig by Mitchell Hashimoto (HashiCorp co-founder). Native UI rendering on macOS and Linux. Supports ligatures, true color, Kitty graphics protocol, and splits/tabs. Configurable via a simple key-value file with sensible defaults. Open-source with 20K+ GitHub stars and a focus on correctness, speed, and minimal resource usage. Growing as a modern alternative to iTerm2, Alacritty, and WezTerm.

Open Source
Claude Code logo

Claude Code

Top Pick

Anthropic's agentic coding CLI

Anthropic's agentic CLI coding tool that delegates complex tasks to Claude directly from the terminal. Understands entire codebases via automatic context gathering, edits multiple files, runs shell commands, and manages Git workflows autonomously. Supports CLAUDE.md for persistent project instructions, integrates with VS Code and JetBrains, and uses Claude Opus/Sonnet with extended thinking for complex architectural decisions. Built for terminal-first developers.

paid
Cursor logo

Cursor

Top Pick

The AI-first code editor

AI-first code editor built as a VS Code fork that deeply integrates LLMs into every part of the development workflow. Features Tab autocomplete with multi-line predictions, Cmd+K inline editing, AI chat with full codebase awareness, and Agent mode for autonomous multi-file edits with terminal execution. Supports GPT-4, Claude, and more with automatic context from project files and docs. Includes privacy mode for SOC 2 compliance. The leading AI-native IDE with 100K+ paying users.

freemiumTelemetry
Codex logo

Codex

Top Pick

OpenAI coding agent for app, editor, terminal, and cloud work

Codex is OpenAI's coding agent for software development across the Codex app, editor, terminal, and cloud tasks. It helps write, review, debug, refactor, and automate code, with ChatGPT plan access for managed surfaces and API-key usage for CLI, SDK, and IDE workflows. The open-source CLI and SDK support local repository work, while cloud features add GitHub review, Slack/Linear integrations, worktrees, skills, MCP, and automations.

freemium
KaibanJS logo

KaibanJS

JavaScript framework for building and visualizing multi-agent workflows on a Kanban board

KaibanJS is an MIT-licensed JavaScript framework for defining AI agents, tasks, tools, and teams, then orchestrating their work through a Kanban-inspired runtime and visual board. It can run inside Node.js, React, or Next.js projects, supports custom UIs and headless workflows, and provides real-time task-state visibility for multi-agent applications.

Open SourceTelemetry

Used in Stacks

Comparisons

code2prompt vs Repomix — Rust CLI Codebase Serializer vs Node.js Prompt Generator

code2prompt and Repomix both convert codebases into LLM-ready prompts, but they differ in language, template systems, and optimization strategies. code2prompt is a Rust CLI with Handlebars templates and token budget management, while Repomix is a Node.js tool focused on intelligent file selection with built-in security checking and multiple output formats for different AI coding workflows.

code2promptRepomix

FAQ

What is code2prompt?

code2prompt is a Rust CLI that converts entire codebases into structured prompts optimized for LLM context windows. It intelligently filters files using gitignore patterns, respects token budgets, generates directory tree visualizations, and supports custom Handlebars templates for output formatting. The tool addresses the core challenge of feeding large codebases to AI coding assistants by producing clean, organized context that maximizes the value of limited token budgets.

Is code2prompt free?

Yes — code2prompt is open source and free to use. Free and open source under MIT License

Is code2prompt open source?

Yes — code2prompt is open source.

What are the best code2prompt alternatives?

The top editor-verified code2prompt alternatives are GStack, Everything Claude Code, Embedder.