{"slug": "how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way", "title": "How to give Claude or ChatGPT your entire codebase (the right way)", "summary": "A developer created ctxpack, a zero-dependency CLI tool that packages an entire codebase into a single file for AI models like Claude and GPT. The tool handles three common problems: it orders files into a single document with a file index, automatically masks secrets like API keys, and estimates token counts to fit within model context windows. ctxpack is MIT-licensed and available on GitHub.", "body_md": "At some point every \"let me just paste my code into the AI\" session hits a wall. You want the model to reason about the *whole* project — not one file — so you start copy-pasting directories. Three things go wrong, usually in this order:\n\nHere's a workflow that handles all three, whether you build the tooling yourself or use an off-the-shelf one.\n\nModels reason better over a single, well-ordered document than over 30 pasted snippets. Walk the repo, skip the noise (`node_modules`\n\n, build output, images, lockfiles), and emit each file with a clear header. A file index at the top helps the model build a mental map before it reads any code.\n\nThis is the step people skip. Anything credential-shaped — `sk-...`\n\n, `ghp_...`\n\n, `AKIA...`\n\n, `sk_live_...`\n\n, `-----BEGIN PRIVATE KEY-----`\n\n— should be masked automatically, not by remembering to check. A prompt log is a place secrets go to leak; treat the bundle like a public paste.\n\nEstimate the bundle's token count and compare it to your target model (Claude ~200K, GPT-5 ~400K, Gemini 2.5 Pro ~1M). If you're over, don't truncate blindly — drop the **largest file bodies** but keep every file **listed**, so the model still knows the project's full shape.\n\n[ctxpack](https://github.com/trongtruong110-ux/ctxpack) is a zero-dependency CLI that does all three:\n\n```\n# whole repo, budgeted for Claude, secrets masked, written to a file\nnpx github:trongtruong110-ux/ctxpack . --model claude-fable-5 -o context.md\n\n# too big? fit it to a budget (keeps the file map, trims largest bodies)\nnpx github:trongtruong110-ux/ctxpack . --fit 150000 -o context.md\nctxpack: 214 files packed\n  tokens: ~147,900  (74% of Claude 200,000 ctx)\n  redacted: 3 secret(s)\n```\n\nThen paste `context.md`\n\n(or attach it) and ask your question against the full project.\n\nctxpack is MIT-licensed and free: [https://github.com/trongtruong110-ux/ctxpack](https://github.com/trongtruong110-ux/ctxpack). If you've got a workflow for feeding whole projects to an LLM, I'd like to hear it.", "url": "https://wpnews.pro/news/how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way", "canonical_source": "https://dev.to/cu_thinvreview_b2/how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way-4nbm", "published_at": "2026-07-04 02:29:24+00:00", "updated_at": "2026-07-04 03:19:17.271143+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "generative-ai", "ai-tools"], "entities": ["ctxpack", "Claude", "GPT", "Gemini", "GitHub", "trongtruong110-ux"], "alternates": {"html": "https://wpnews.pro/news/how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way", "markdown": "https://wpnews.pro/news/how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way.md", "text": "https://wpnews.pro/news/how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way.txt", "jsonld": "https://wpnews.pro/news/how-to-give-claude-or-chatgpt-your-entire-codebase-the-right-way.jsonld"}}