๐Ÿ“ฆ v0.1.0 ยท Go 1.26 ยท zero deps

GopherCram

A small Go CLI that packs a software repository into a single AI-friendly file โ€” XML, Markdown, JSON, or plain text โ€” with a gitignore-aware walker, an embedded secret scanner, an approximate token counter, and built-in remote-repo cloning.

GopherCram

What's in the box

๐Ÿ“ Smart traversal

Default ignore patterns plus per-directory .gitignore, .ignore, and .gophercramignore rules, all merged with last-match-wins semantics.

๐Ÿงพ Four output styles

XML (CDATA-wrapped), Markdown (fenced blocks with language hints), JSON (stable shape, easy to post-process), and plain text.

๐Ÿ” Secret scanner

Regex-driven detection of AWS, GitHub, Stripe, Slack, Google, JWT, PEM, and connection-string secrets โ€” with entropy-based false-positive filtering.

๐Ÿงฎ Token estimator

Calibrated against GPT-4 tokenizers; matches tiktoken within ~6% on the bundled fixture without shipping a vocabulary file.

โœ‚๏ธ Comment + body strip

Language-aware comment lexers for C-style, hash, Lua, SQL, and XML comments. Optional compression keeps signatures and drops function bodies for skim-only context.

๐ŸŒ Remote clone

Pass --remote owner/repo or any clone URL; GopherCram clones into a temp dir, packs, and cleans up after itself.

๐Ÿ“ˆ Git-aware

Sort files by change frequency, append working-tree / staged diffs, and embed a recent commit log.

๐Ÿ“ฆ Split output

Chunk the packed file at a configured size cap (--split-output 2mb) when you need to ship it through size-limited channels.

๐Ÿน Pure Go stdlib

No third-party dependencies. One static binary, no surprises.

Install

Pre-built binaries are not shipped yet โ€” build from source:

$ git clone https://github.com/rajathjn/GopherCram.git
$ cd GopherCram
$ go build -o gophercram ./
# puts the static binary at ./gophercram

30-second tour

$ gophercram
GopherCram v0.1.0 โ€” packing 1 root(s)
wrote /repo/gophercram-output.xml
Summary:
  files:   38
  chars:   140172
  tokens:  ~66356
  bytes:   140212 (136.93 KB)
$ gophercram --style markdown --output context.md src/ docs/
$ gophercram --remote owner/repo --remote-branch main
$ gophercram --stdout --remove-comments --compress | pbcopy

How it looks

XML output

<gophercram>
  <summary>
    <producer>GopherCram v0.1.0</producer>
    <stats files="38" tokens="66356"/>
  </summary>
  <directory_structure><![CDATA[
src/
  api/
    users.ts
    products.ts
  utils/
    format.ts
]]></directory_structure>
  <files>
    <file path="src/api/users.ts">
      <![CDATA[ ...content... ]]>
    </file>
  </files>
</gophercram>

Markdown output

# GopherCram Output

> Packed by **GopherCram** v0.1.0

| Metric | Value |
|---|---|
| Files | 38 |
| Tokens (approx) | 66356 |

## Files

### `src/api/users.ts`

```ts
export async function fetchUsers() { ... }
```

Configuration in one file

Run gophercram --init to drop a defaulted config in your project root. Every field is optional; omitted fields inherit the defaults.

{
  "$schema": "https://gophercram.dev/schema.json",
  "input": { "maxFileSize": 52428800 },
  "output": {
    "filePath": "gophercram-output.xml",
    "style": "xml",
    "fileSummary": true,
    "directoryStructure": true,
    "files": true,
    "topFilesLength": 5,
    "git": {
      "sortByChanges": true,
      "sortByChangesMaxCommits": 100,
      "includeLogsCount": 50
    }
  },
  "include": [],
  "ignore": {
    "useGitignore": true,
    "useDotIgnore": true,
    "useDefaultPatterns": true,
    "customPatterns": []
  },
  "security": { "enableSecurityCheck": true },
  "tokenCount": { "encoding": "approx" }
}

Testing & comparison

The repository ships a synthetic TypeScript fixture (test/fixtures/dummy-ts-repo) plus an opt-in integration suite that runs npx repomix on the same fixture and cross-checks the file list and token totals.

$ go test ./...
ok internal/cli 0.546s
ok internal/config 1.870s
ok internal/fileselect 0.977s
ok internal/security 4.204s
โ€ฆ
$ GOPHERCRAM_INTEGRATION=1 go test ./test/integration/... -v
PASS: TestCompare_FileCoverage
PASS: TestCompare_TokenCountSimilar (ratio 1.06)

Docs