Skip to content

Getting Started

Bundle your codebase into LLM-optimized context files. Get precise, grounded answers from ChatGPT, Claude, Gemini, and other AI tools.

Prerequisites

  • Node.js 22.18+ or Bun
  • A codebase you want to share with AI

Quick Start

sh
npx srcpack init
sh
bunx srcpack init
sh
pnpm dlx srcpack init
sh
yarn dlx srcpack init

This creates a srcpack.config.ts file with bundles based on your project structure.

Then run:

sh
npx srcpack
sh
bunx srcpack
sh
pnpm dlx srcpack
sh
yarn dlx srcpack

Your bundles are now in .srcpack/ — ready to upload to any AI chat.

Your First Bundle

Create srcpack.config.ts in your project root:

ts
import { defineConfig } from "srcpack";

export default defineConfig({
  bundles: {
    app: "src/**/*",
  },
});

Run the bundle command and you'll see:

  app  12 files  240 lines  → .srcpack/app.txt

Bundled: 1 bundle, 12 files, 240 lines

Understanding the Output

Srcpack generates an indexed bundle optimized for AI consumption:

text
# Index (3 files)
# [1]   src/api.ts  L7-L67 (61 lines)
# [2]   src/index.ts  L69-L110 (42 lines)
# [3]   src/utils.ts  L112-L158 (47 lines)

#==> [1] src/api.ts <==
export async function fetchBoard() {
...

#==> [2] src/index.ts <==
import { utils } from "./utils";
...

Why this format matters:

  • Numbered index — AI can reference [2] src/utils.ts in responses
  • Line numbers — Answers include exact locations like L43-L89
  • # prefix — Safe to paste inside markdown code blocks

When you ask "How does the auth flow work?", AI responds with:

The auth flow starts in [3] src/api.ts:L92 where...

Using with AI

  1. Open ChatGPT, Claude, or your preferred AI
  2. Upload .srcpack/app.txt or paste its contents
  3. Ask questions about your code

Example prompts:

  • "Explain how the main entry point works"
  • "Find where errors are handled"
  • "What would break if I renamed the User type?"

The AI answers are grounded in your actual code, with file and line references.

Configuration Patterns

Multiple Bundles

Split your codebase into semantic domains:

ts
export default defineConfig({
  bundles: {
    web: "apps/web/**/*",
    api: "apps/api/**/*",
    shared: "packages/shared/**/*",
  },
});

Exclusions

Use ! prefix to exclude patterns:

ts
export default defineConfig({
  bundles: {
    api: ["src/**/*", "!src/**/*.test.ts", "!src/**/*.spec.ts"],
  },
});

Custom Output Path

ts
export default defineConfig({
  bundles: {
    docs: {
      include: "docs/**/*.md",
      outfile: "~/Downloads/docs-bundle.txt",
    },
  },
});

Review Bundle

Bundle what you changed instead of a fixed set of paths:

ts
export default defineConfig({
  bundles: {
    review: {
      include: ["git:staged", "!bun.lock"],
      prompt: "Review these changes for correctness.",
    },
  },
});

See Git sources for git:dirty, git:main, and the rest.

Code and Tickets Together

A bundle can include Linear issues next to your code, so the LLM sees both the intent and the implementation:

ts
export default defineConfig({
  bundles: {
    planning: {
      include: ["src/**/*.ts", "docs/**/*.md"],
      linear: { team: "ENG", project: "Roadmap" },
      prompt: "Which roadmap items are already implemented?",
    },
  },
});

Each issue becomes its own indexed entry (linear/issues/ENG-123.md). Set LINEAR_API_KEY in your environment first — see Linear issues.

CLI Reference

sh
npx srcpack              # Bundle all
npx srcpack web api      # Bundle specific bundles only
npx srcpack --staged     # Bundle staged changes (no config needed)
npx srcpack --dry-run    # Preview without writing
npx srcpack --no-upload  # Skip upload even if configured
sh
bunx srcpack              # Bundle all
bunx srcpack web api      # Bundle specific bundles only
bunx srcpack --staged     # Bundle staged changes (no config needed)
bunx srcpack --dry-run    # Preview without writing
bunx srcpack --no-upload  # Skip upload even if configured
sh
pnpm dlx srcpack              # Bundle all
pnpm dlx srcpack web api      # Bundle specific bundles only
pnpm dlx srcpack --staged     # Bundle staged changes (no config needed)
pnpm dlx srcpack --dry-run    # Preview without writing
pnpm dlx srcpack --no-upload  # Skip upload even if configured
sh
yarn dlx srcpack              # Bundle all
yarn dlx srcpack web api      # Bundle specific bundles only
yarn dlx srcpack --staged     # Bundle staged changes (no config needed)
yarn dlx srcpack --dry-run    # Preview without writing
yarn dlx srcpack --no-upload  # Skip upload even if configured

Next Steps