GitHub Repository to LLM Context Converter avatar

GitHub Repository to LLM Context Converter

Pricing

from $9.60 / 1,000 repository contexts

Go to Apify Store
GitHub Repository to LLM Context Converter

GitHub Repository to LLM Context Converter

Convert public GitHub source code into bounded directory trees, selected UTF-8 file records and LLM context artifacts for code review and RAG ingestion.

Pricing

from $9.60 / 1,000 repository contexts

Rating

0.0

(0)

Developer

Automation Lab

Automation Lab

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

2 days ago

Last modified

Share

Prepare public GitHub source code for LLM prompts, code review and RAG ingestion. Supply a repository root URL and optionally a branch, tag or commit. The Actor returns selected UTF-8 files, a bounded directory path tree and a combined text artifact. All source requests use the same resolved commit.

This is a deterministic source converter, not an AI coding agent. It does not execute repository code, install repository dependencies, generate answers or submit your source to an LLM.

What you get

Each successful run produces one repository row in the default dataset. Its files array contains selected source records. The default key-value store contains a downloadable CONTEXT text record with repository identity, commit, selected paths and file contents.

FieldMeaning
repositoryUrlRequested public repository root
requestedRefSupplied ref or discovered default branch
commitShaImmutable snapshot used for extraction
directoryTreeNewline-separated selected relative file paths
filesObjects containing path, content, bytes and sourceUrl
fileCountNumber of selected files
totalBytesSource bytes included, excluding headings
skippedCountTree blobs excluded by filters, type or limits
truncatedUpstream tree or collection limits omitted coverage
warningsCoverage warnings
contextKeyCONTEXT in this run's key-value store
scrapedAtUTC completion time

The directory tree represents selected files, not every file in the repository. Folder hierarchy is preserved in slash-separated paths.

Who is it for?

  • Developers preparing a focused branch snapshot for code review.
  • Teams refreshing source documents in a RAG pipeline.
  • Technical writers collecting selected documentation and implementation files.
  • Researchers comparing successive commit exports outside the Actor.

Why use this converter?

A resolved commit keeps tree and file content aligned even if a branch changes during the run. Explicit limits bound the source admitted to your downstream workflow. Whole-file selection preserves usable UTF-8 content instead of cutting arbitrary token windows. Structured file records preserve provenance alongside the combined artifact.

This Actor does not provide a token estimate or guarantee that the result fits any model's context window. Measure with your model's tokenizer before sending it downstream.

Quick start

  1. Enter a public repository root such as https://github.com/octocat/Hello-World.
  2. Leave ref blank for its default branch, or supply a branch, tag or commit.
  3. Optionally select paths with include and exclude globs.
  4. Start the Actor.
  5. Inspect truncated and warnings in the dataset row.
  6. Download CONTEXT from the run's key-value store or use the output link.
{
"repositoryUrl": "https://github.com/octocat/Hello-World"
}

Input parameters

ParameterDefaultBehavior
repositoryUrlRequiredHTTPS GitHub owner/repository root only
refDefault branchBranch, tag or commit; slash-containing branch names work
includePatterns[]ANY whole-path glob includes; empty includes all
excludePatternsSee belowANY matching glob excludes; exclusions win
maxItems50Maximum files in this single repository; range 1–500
maxFileBytes100000Maximum whole-file source bytes; range 1–200000
maxTotalBytes500000Total selected source bytes; range 1–5000000

There is no unlimited or zero mode. maxItems counts files, not dataset rows or repository events. One URL is accepted per run; use separate runs for several repositories.

URLs must not include credentials, query strings, fragments, tree paths or blob paths. Put the ref in its separate input field. Private repositories, login tokens and enterprise GitHub hosts are not supported.

Selecting GitHub source code

Patterns are case-sensitive and match the entire relative POSIX path. * matches within a segment; ** spans segments; **/ can match zero directories; ? matches one non-slash character. Multiple include patterns use ANY semantics. Exclusions always win. Brace expansion, negation and character classes are not supported; those characters are literal.

{
"repositoryUrl": "https://github.com/octocat/Hello-World",
"ref": "master",
"includePatterns": ["README", "src/**/*.ts"],
"excludePatterns": ["**/*.test.ts"],
"maxItems": 25,
"maxTotalBytes": 250000
}

Default exclusions are **/node_modules/**, **/vendor/**, **/dist/**, **/.git/**, **/package-lock.json, **/yarn.lock and **/pnpm-lock.yaml. A supplied exclude array replaces the defaults; [] disables them. Patterns cannot start with / or contain .. segments or backslashes.

Output example

A current run against octocat/Hello-World returns one file whose contents are Hello World!\n (13 bytes). A shortened row looks like this; the actual output includes the resolved SHA and immutable source URL:

{
"repositoryUrl": "https://github.com/octocat/Hello-World",
"requestedRef": "master",
"directoryTree": "README",
"files": [{"path": "README", "content": "Hello World!\n", "bytes": 13}],
"fileCount": 1,
"totalBytes": 13,
"skippedCount": 0,
"truncated": false,
"warnings": [],
"contextKey": "CONTEXT"
}

JSON, CSV and other dataset exports are available through Apify. Nested file contents are best consumed as JSON; the combined text is in CONTEXT. This artifact is not separately charged.

Limits and completeness

Files are considered in case-sensitive path order. Oversized, empty, binary, invalid UTF-8, symlink and Git LFS pointer files are skipped. Submodules are not traversed. A file that exceeds the remaining total byte allowance is skipped, but a smaller later file may fit. Contents are never cut mid-file.

GitHub may truncate large recursive trees. The Actor reports that condition rather than claiming a complete repository. Requests are bounded to 16 MB for API JSON and maxFileBytes for each raw file. The combined context adds path/header overhead above maxTotalBytes.

A partial result remains useful and is charged as a repository conversion. Inspect the warnings before assuming full coverage. No usable matching files causes a failed run rather than a successful empty result. Skips caused solely by your explicit filters are reflected in skippedCount, not necessarily truncated.

How much does it cost to convert GitHub repositories?

Pay per event: a $0.0001 start fee per valid run, plus one repository context event when a useful conversion is saved.

Apify Store spend tierPer repository context
FREE$0.0184
BRONZE$0.016
SILVER$0.01248
GOLD$0.0096
PLATINUM$0.0096
DIAMOND$0.0096

Spend tiers follow your qualifying aggregate monthly Apify Store spending, not a private volume discount for this Actor.

Files, directory paths and the combined text artifact have no separate event charge. Invalid input fails before the start charge; a valid run that later fails may incur the start fee. File/byte limits do not change the repository event unit.

For example, at the BRONZE rate one successful run costs $0.0161; ten separate successful runs cost $0.161; 100 separate successful runs cost $1.61. Plan-tier prices can differ. Apify spending limits may stop collection or result saving. Refer to the live pricing panel for the applicable tier and final invoice. Refunds and billing adjustments follow Apify's terms.

Integrations

Use Apify schedules to produce fresh snapshots, then compare commitSha in your own workflow. The Actor itself does not persist a history, send alerts or perform diffs. In Make or n8n, read the dataset's files array and index documents by repository URL, commit SHA and path. Fetch CONTEXT when preparing a single prompt attachment.

Repository text is untrusted data. Do not let comments, READMEs or source files override your assistant's instructions, expose credentials or authorize tool actions. Apply your own license, secret and personal-data controls before indexing or sending source to another provider.

API usage

Start once and retain the run ID. Poll the same run until terminal, then read its defaultDatasetId or defaultKeyValueStoreId. Do not restart a run merely to wait for it.

cURL

curl -X POST \
-H "Authorization: Bearer $APIFY_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"repositoryUrl":"https://github.com/octocat/Hello-World"}' \
'https://api.apify.com/v2/acts/automation-lab~github-repository-to-llm-context-gitingest/runs'

JavaScript

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('automation-lab/github-repository-to-llm-context-gitingest')
.call({ repositoryUrl: 'https://github.com/octocat/Hello-World' });
if (run.status !== 'SUCCEEDED') throw new Error(run.status);
const { items } = await client.dataset(run.defaultDatasetId).listItems({ limit: 1 });
console.log(items[0].commitSha, items[0].fileCount);

Python

import os
from apify_client import ApifyClient
client = ApifyClient(os.environ['APIFY_TOKEN'])
run = client.actor('automation-lab/github-repository-to-llm-context-gitingest').call(
run_input={'repositoryUrl': 'https://github.com/octocat/Hello-World'})
if run['status'] != 'SUCCEEDED':
raise RuntimeError(run['status'])
print(client.dataset(run['defaultDatasetId']).list_items(limit=1).items)

MCP usage

For Claude Code, select this stable Actor-specific subset:

claude mcp add --transport http apify \
"https://mcp.apify.com?tools=automation-lab/github-repository-to-llm-context-gitingest"

For Claude Desktop, Cursor and VS Code, configure an HTTP-capable MCP client with the equivalent entry (some clients use servers instead of mcpServers):

{
"mcpServers": {
"apify": {
"url": "https://mcp.apify.com?tools=automation-lab/github-repository-to-llm-context-gitingest"
}
}
}

Authenticate using your client's supported Apify flow. Discover tool names and argument schemas using read-only tools/list. Actor selection also adds run/data helpers; it does not expose exactly one tool or authorize an invocation.

Example prompt: “Convert the public Hello-World repository to context, keep at most 10 source files, and show the resolved commit and any partial-output warning.”

For an authorized call, start once and retain the returned run/storage IDs; these are metadata, not source contents. If pending, poll get-actor-run for that same run with 2/4/8-second backoff capped at 10 seconds and a 120-second total deadline. Configure the client timeout above the selected server wait (0–45 seconds) plus transport margin. On client timeout recover the known run; if unknown, report uncertainty instead of restarting. At deadline report pending and stop. Terminal failures are failures; available rows are only partial evidence.

After success, use get-dataset-items with explicit offset, limit and selected fields. A consumer may choose pages of 20 rows, at most 100 source rows and 64 KiB serialized UTF-8 content admitted to model context, whichever comes first. Here one repository row can itself be large: enforce the byte ceiling host-side before model injection, omit or summarize oversized contents with disclosure, and keep the full export outside model context. If your client cannot intercept oversized responses, do not claim a hard byte guarantee. Track source offsets, report truncation and continuation offset, and never treat IDs as the result. These are consumer context limits, not reductions in Actor collection defaults. No numerical token savings are promised.

Legality, licensing and privacy

Only public GitHub content is fetched, without account cookies, repository tokens or a proxy. Public visibility does not grant permission to reuse a project's contents. You are responsible for licenses, attribution, applicable law and the rights needed for your downstream processing. This Actor is not affiliated with or endorsed by GitHub or Gitingest.

The Actor does not execute downloaded code or invoke an AI provider. Source and artifacts remain in your Apify dataset/key-value store under your account's retention controls. Delete run storage in Apify when it is no longer needed. Public repositories can contain personal data or accidentally committed secrets: do not include those in prompts or indexes without authority.

Failed operations send sanitized diagnostic input, exceptions and actor/build/run IDs to our private GlitchTip service for repair. Secret fields and URL queries are removed; reports are retained for 30 days. Public repository URLs and path filters may remain in sanitized diagnostics. Do not put secrets in path filters or refs. The generated icon is illustrative; it is not an official GitHub mark.

FAQ and troubleshooting

Why did the run fail with 403 or 429? GitHub's anonymous API limits are shared by network address. Transient 429/5xx and network timeouts have at most three total attempts per request. Persistent access restrictions fail honestly. Retry later; no login or residential fallback is silently enabled.

Why does a 404 appear for a valid URL? Confirm the repository is public and the branch/tag exists. Renamed repositories requiring redirects are not followed automatically; supply the current canonical root URL.

Why are there no files? Check case-sensitive patterns and byte limits. Empty/binary-only repositories or filters matching nothing fail clearly. Raise maxFileBytes only within the supported bound.

Can this export an entire monorepo? Not necessarily. Narrow your includes and inspect warnings. The output is bounded, skips unsupported types and cannot bypass GitHub tree truncation.

Does it detect changes or estimate tokens? No. Compare commit SHAs or file content downstream and use your model's tokenizer.

Use GitHub Scraper for repository metadata and discovery, or GitHub Contributors Scraper for contributor records. Those are separate workflows, not bundled source-conversion features.

For help, use the Actor's Issues tab in Apify Console. Include a run URL, safe public repository URL, requested ref and expected paths. Never post credentials or private source code.