Back
33/65
Lesson 33
6 min
S2P: Source to Prompt
Combine source code into LLM-ready prompts with token counting
Ready to level up?
Mark complete to track your learning progress.
Combine source code into LLM-ready prompts with token counting
Mark complete to track your learning progress.
Combine source code files into LLM-ready prompts with interactive file selection and token counting.
S2P (Source to Prompt TUI) is a terminal-based tool for combining source code files into a single, LLM-ready prompt. It provides an interactive file browser where you can select exactly which files to include, see the combined output in real-time, and track your token count as you go.
Crafting prompts with code context is tedious when done manually. S2P lets you interactively navigate your codebase, toggle files on/off, preview the combined output, and copy everything to your clipboard in one keystroke. It respects your .gitignore automatically.
Browse and toggle files visually
tiktoken-accurate, real-time
One keystroke to copy output
Respects .gitignore automatically
Once you launch S2P, you get an interactive file browser. Here are the key controls:
# Keyboard Controls↑/↓ Navigate between filesSpace Toggle file selectionEnter Expand/collapse directoriesa Select all filesn Deselect all filesc Copy to clipboardq / Esc Quit
The interface shows you the total token count in real-time as you select files. This helps you stay within Claude's or GPT's context window limits.
Explore different project types below. Toggle source files, apply glob filters, and watch S2P scan, measure, and combine them into a single LLM-ready prompt.
Next.js frontend with components and hooks — context: 32K
Select files to preview prompt
Toggle files in the tree or use Select All
# Navigate to your projectcd /data/projects/my-app# Launch S2Ps2p# In the TUI:# 1. Navigate to src/ directory# 2. Select relevant TypeScript files# 3. Watch token count update# 4. Press 'c' to copy to clipboard# Now paste into Claude/GPT with your question:# "Here's my source code. Can you help me..."
S2P works great alongside other flywheel tools: