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
s2p takes only a directory.Once you launch S2P, you get an interactive file browser. Here are the key controls:
# Keyboard Controlsj/k or ↑/↓ Move cursorh/l or ←/→ Collapse/expand directorySpace/Enter Toggle file / expand directory/ or f Filter by patha / A Select / deselect files matching the filterCtrl+G Generate combined prompty / w Copy / save (output view)Esc (twice) 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 a file filter, 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 Ctrl+G to generate, then 'y' to copy# Now paste into Claude/GPT with your question:# "Here's my source code. Can you help me..."
S2P works great alongside other flywheel tools: