πŸš€Debugging Microservices & Distributed Systems

Trevor I. Lasn

Staff Software Engineer & Engineering Manager

5 min read

Repopack: Pack Your Entire Repository Into A Single File

A tool that packages your code to easily share with LLM models.

Repopack is a new open-source tool I’ve been testing out. It’s designed to help developers work more efficiently with LLM coding assistants. It tackles a common headache for developers: efficiently sharing entire codebases with large language models.

Most LLM models have strict token limits, making it tough to share large codebases or complex project structures. This often leads to a tedious process of manually copying and pasting relevant code snippets, which is not only time-consuming but also prone to errors.

Another issue is the inconsistent formatting across different parts of a project, which can sometimes confuse LLM models. There’s also the ever-present worry of accidentally sharing sensitive information when selecting code to share.

Most importantly, when we only share isolated parts of a project with an LLM assistant, we rob it of the broader context. This can lead to suggestions that don’t quite fit with the overall architecture or project goals.

What is Repopack?

At its core, Repopack is a command-line tool that packages your entire code repository into a single file. This file is formatted in a way that’s easy for LLM models like GPT-4, Claude, or Gemini to process.

Terminal window
➜ trevorlasn.com git:(master) βœ— repopack --include "src"
πŸ“¦ Repopack v0.1.43
βœ” Packing completed successfully!
πŸ“ˆ Top 5 Files by Character Count and Token Count:
──────────────────────────────────────────────────────
1. src/content/blog/benchmarks-for-node-bun-deno/index.md (65603 chars, 11330 tokens)
2. src/content/blog/common-causes-of-memory-leaks-in-javascript/index.md (42041 chars, 11181 tokens)
3. src/content/blog/google-journey-from-search-engine-to-tech-giant/index.mdx (24245 chars, 5025 tokens)
4. src/content/blog/micro-frontends-what-they-are-and-when-to-use/index.mdx (19897 chars, 5958 tokens)
5. src/content/blog/10-essential-terminal-commands-every-developer-should-know/index.md (18327 chars, 4892 tokens)
πŸ”Ž Security Check:
──────────────────
βœ” No suspicious files detected.
πŸ“Š Pack Summary:
────────────────
Total Files: 123
Total Chars: 738930
Total Tokens: 167841
Output: repopack-output.txt
Security: βœ” No suspicious files detected
πŸŽ‰ All Done!
Your repository has been successfully packed.

Now if I want to share my project with LLM models, I can simply send them the repopack-output.txt file. This way, the LLM model can see the entire project structure and context, making it easier to provide relevant suggestions.

================================================================
Repository Structure
================================================================
src/
components/
ArrowCard.jsx
BackToPrev.astro
BackToTop.astro
Container.astro
ContentContainer.astro
Footer.astro
FormattedDate.astro
Head.astro
Header.astro
InfiniteScrollPosts.jsx
Link.astro
SearchModal.astro
ThemeSwitcher.tsx
content/
blog/
explicit-is-better-than-implicit/
index.mdx
10-essential-terminal-commands-every-developer-should-know/
index.md
2020-programming-trend-predictions/
index.md
39-percent-companies-losing-control-of-it-and-security/
index.mdx
a-company-is-not-a-family-its-a-sports-team/
index.mdx
a-great-product-doesnt-need-marketing/
index.md
ageism-in-tech/
index.mdx
aggregate-error-in-javascript/
index.md
all-you-need-to-know-about-css-in-js/
index.md
amazon-rise-to-tech-titan/
index.mdx
amazons-no-weasel-words-rule/
index.md
astro-capo/
index.mdx
attracting-top-engineering-talent/
index.md
become-a-web-developer-in-180-days/
index.md
being-a-self-taught-developer/
index.mdx
benchmarks-for-node-bun-deno/
index.md
build-your-army/
index.mdx
cloudflare-ai-content-control/
index.mdx
code-wins-arguments/
index.md
common-causes-of-memory-leaks-in-javascript/
index.md
conways-Law/
index.mdx
csp-headers-astro/
index.mdx
culture-happens-outside-management/
index.md
demystifying-react-hooks/
index.md
dependency-time-machine/
index.md
docker-with-react/
index.md
easy-guide-for-webpack-2-0-from-scratch/
index.md
embrace-early-returns-and-intermediate-variables-for-readable-code/
index.md
engineering-managers-should-write-code/
index.md
eslint-plugin-depend/
index.md
evolve-or-become-irrelevant/
index.md
frontend-security-checklist/
index.md
google-chrome-built-in-gemini-nano/
index.md
google-is-killing-information-economics-on-the-internet/
index.md
google-journey-from-search-engine-to-tech-giant/
index.mdx
how-to-fetch-data-from-an-api-with-react-hooks/
index.md
how-to-launch-software-projects-on-time-and-on-budget/
index.mdx
how-to-restore-your-passion-for-programming/
index.md
how-to-use-redux-with-react-hooks/
index.md
increase-react-redux-application-performance-with-reselect-library/
index.md
internal-mobility/
index.mdx
invisible-columns-in-sql/
index.md
is-void-zero-a-threat-to-open-source/
index.mdx
its-more-fun-to-be-competent/
index.md
lazy-loading-iframes/
index.md
make-it-work-first-before-you-optimize/
index.mdx
mental-toughness-is-the-best-quality-a-developer-can-have/
index.md
mermaid-create-charts-and-diagrams-with-markdown/
index.md
micro-frontends-what-they-are-and-when-to-use/
index.mdx
minimum-viable-documentation/
index.mdx
next-js-react-server-side-rendering-done-right/
index.md
objective-c-is-the-ugliest-programming-language-and-a-total-abomination/
index.md
open-dyslexic-font/
index.mdx
outdated-docs-are-tech-debt/
index.md
peaks-js-interact-with-audio-waveforms/
index.md
preconnect-to-required-origins/
index.md
react-lazy-loading/
index.md
react-testing-mock-service-worker/
index.md
repopack/
index.mdx
setImmediate-vs-setTimeout-in-javascript/
index.md
sharp-high-performance-node-js-image-processing-library/
index.md
small-habits-big-impact/
index.mdx
software-engineer-titles-have-almost-lost-all-their-meaning/
index.mdx
specialist-vs-generalist-choosing-your-career-path/
index.mdx
speculation-rules-api/
index.md
start-with-the-bigger-picture/
index.mdx
staying-motivated-while-building/
index.md
take-your-writing-seriously/
index.md
technical-debt-is-killing-your-business/
index.md
the-art-of-effective-onboarding/
index.mdx
the-barnacle-strategy/
index.mdx
the-credit-vacuum/
index.mdx
the-crutch-effect/
index.md
the-internet-is-becoming-an-ocean-of-LLM-generated-junk/
index.md
the-only-javascript-feature-that-was-deprecated/
index.md
the-real-cost-of-meetings/
index.md
the-secret-to-being-a-top-developer-is-building-things/
index.md
the-what-why-and-how-of-using-a-skeleton-loading-screen/
index.md
tips-for-reducing-cyclomatic-complexity/
index.md
understanding-javascript-closures/
index.md
understanding-vue-suspense/
index.md
unrealistic-deadlines-in-software-engineering/
index.md
users-can-be-fired/
index.md
week-of-coding-can-save-you-hours-of-planning/
index.md
what-does-an-entry-level-programmer-need-to-know-exactly/
index.md
what-made-apple-great/
index.mdx
what-makes-mrbeast-so-successful/
index.md
whats-holding-you-back/
index.mdx
whats-new-in-express-5/
index.mdx
when-regex-goes-wrong/
index.md
when-should-you-actually-worry-about-tech-debt/
index.md
write-documentation-like-a-journalist/
index.md
your-repo-is-a-leaky-ship-probably/
index.md
config.ts
layouts/
PageLayout.astro
lib/
utils.ts
pages/
blog/
[...slug].astro
otto/
index.astro
topics/
[topic].astro
index.astro
404.astro
index.astro
robots.txt.ts
rss.xml.ts
styles/
global.css
utils/
filterPublishedPosts.ts
isDraftPost.ts
consts.ts
env.d.ts
types.ts
================================================================
Repository Files
================================================================
================
File: src/components/ArrowCard.jsx
================
import React from 'react';
import { readingTime } from "@lib/utils";
const ArrowCardReact = ({ entry }) => {
{* yeah not sharing this, haha *}

Think of Repopack like a tar designed specifically for feeding codebases to LLMs. It’s tailored for the unique requirements of working with large language models in a coding context.

Sharing the repopack-output.txt with large language models

Once you’ve generated your repopack-output.txt file, you can easily share it with various AI coding assistants. Here’s how it looks when used with two popular platforms:

Claude

Claude

ChatGPT

ChatGPT

As you can see, both Claude and ChatGPT can easily process the repopack-output.txt file, allowing them to understand your entire codebase context when providing assistance.

Basic Usage

Getting started with Repopack is straightforward:

Terminal window
npm install -g repopack

Run it in your project directory:

Terminal window
repopack

To pack specific files or directories using glob patterns:

Terminal window
repopack --include "src/**/*.ts,**/*.md"

Finally, find the repopack-output.txt file in your current directory.

Key Features

  • Simplicity: It’s a one-command operation to package your repo.
  • AI-Optimized: The output is formatted for easy consumption by AI models.
  • Token Awareness: It provides token counts, helping you stay within AI model limits.
  • Customizable: You can configure what to include or exclude.
  • Security-Minded: It respects .gitignore files and uses Secretlint to avoid exposing sensitive info.

A Word of Caution

While Repopack is useful, it’s important to use it thoughtfully:

  1. Security: Always double-check that sensitive information isn’t included in the output.
  2. AI Limitations: Remember that AI tools, while powerful, aren’t infallible. Use their suggestions as a starting point, not gospel.
  3. Context Matters: Sometimes, less is more. Consider if the AI really needs your entire codebase or just specific parts.

Use it wisely, always be mindful of security concerns, and don’t forget that your expertise and judgment are still the most valuable assets in any development project.

References


Related Articles

If you enjoyed this article, you might find these related pieces interesting as well.

Recommended Engineering Resources

Here are engineering resources I've personally vetted and use. They focus on skills you'll actually need to build and scale real projects - the kind of experience that gets you hired or promoted.

Imagine where you would be in two years if you actually took the time to learn every day. A little effort consistently adds up, shaping your skills, opening doors, and building the career you envision. Start now, and future you will thank you.


This article was originally published on https://www.trevorlasn.com/blog/repopack. It was written by a human and polished using grammar tools for clarity.

Interested in a partnership? Shoot me an email at hi [at] trevorlasn.com with all relevant information.