# GitHub Repository to LLM Context Converter (`automation-lab/github-repository-to-llm-context-gitingest`) Actor

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

- **URL**: https://apify.com/automation-lab/github-repository-to-llm-context-gitingest.md
- **Developed by:** [Automation Lab](https://apify.com/automation-lab) (community)
- **Categories:** Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.60 / 1,000 repository contexts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GitHub Repository to LLM Context Converter

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.

| Field | Meaning |
| --- | --- |
| repositoryUrl | Requested public repository root |
| requestedRef | Supplied ref or discovered default branch |
| commitSha | Immutable snapshot used for extraction |
| directoryTree | Newline-separated selected relative file paths |
| files | Objects containing path, content, bytes and sourceUrl |
| fileCount | Number of selected files |
| totalBytes | Source bytes included, excluding headings |
| skippedCount | Tree blobs excluded by filters, type or limits |
| truncated | Upstream tree or collection limits omitted coverage |
| warnings | Coverage warnings |
| contextKey | `CONTEXT` in this run's key-value store |
| scrapedAt | UTC 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.

```json
{
  "repositoryUrl": "https://github.com/octocat/Hello-World"
}
```

### Input parameters

| Parameter | Default | Behavior |
| --- | --- | --- |
| repositoryUrl | Required | HTTPS GitHub owner/repository root only |
| ref | Default branch | Branch, tag or commit; slash-containing branch names work |
| includePatterns | \[] | ANY whole-path glob includes; empty includes all |
| excludePatterns | See below | ANY matching glob excludes; exclusions win |
| maxItems | 50 | Maximum files in this single repository; range 1–500 |
| maxFileBytes | 100000 | Maximum whole-file source bytes; range 1–200000 |
| maxTotalBytes | 500000 | Total 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.

```json
{
  "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:

```json
{
  "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 tier | Per 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

```bash
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

```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

```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:

```bash
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`):

```json
{
  "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.

### Related Actors and support

Use [GitHub Scraper](https://apify.com/automation-lab/github-scraper) for repository metadata and discovery, or [GitHub Contributors Scraper](https://apify.com/automation-lab/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.

# Changelog

This Actor's version history is a separate document: https://apify.com/automation-lab/github-repository-to-llm-context-gitingest/changelog.md

# Actor input Schema

## `repositoryUrl` (type: `string`):

HTTPS repository root URL only: https://github.com/owner/repo. No tree/blob paths, credentials, query or fragment. Public repositories only.

## `ref` (type: `string`):

Optional branch, tag or full commit SHA. Defaults to the repository default branch. Resolved once to an immutable commit for all files; slash-containing branch names are supported.

## `includePatterns` (type: `array`):

Case-sensitive relative POSIX globs matched against the entire file path; ANY pattern includes a file. Empty array includes all paths. \* matches within one path segment, \*\* across segments, \*\*/ also matches root files, ? one non-slash character. Exclusions always win.

## `excludePatterns` (type: `array`):

Case-sensitive whole-path globs with the same syntax as includePatterns; ANY match excludes. Replaces defaults when supplied; \[] disables default exclusions. No negation, brace expansion or character classes.

## `maxItems` (type: `integer`):

Maximum accepted UTF-8 files in this single repository, not dataset rows. Files are considered in case-sensitive path order after filters. No zero/unlimited mode. Output is one repository row.

## `maxFileBytes` (type: `integer`):

Skip files larger than this many UTF-8 source bytes. Whole files only; contents are never cut mid-file. Binary, empty, symlink and Git LFS pointer files are skipped.

## `maxTotalBytes` (type: `integer`):

Maximum combined accepted file bytes for the repository. A file that does not fit is skipped; later smaller files may fit. Context headings and path tree add overhead. Partial output sets truncated=true; not a token limit.

## Actor input object example

```json
{
  "repositoryUrl": "https://github.com/octocat/Hello-World",
  "includePatterns": [],
  "excludePatterns": [
    "**/node_modules/**",
    "**/vendor/**",
    "**/dist/**",
    "**/.git/**",
    "**/package-lock.json",
    "**/yarn.lock",
    "**/pnpm-lock.yaml"
  ],
  "maxItems": 10,
  "maxFileBytes": 100000,
  "maxTotalBytes": 500000
}
```

# Actor output Schema

## `dataset` (type: `string`):

Structured repository and source files.

## `context` (type: `string`):

Combined text context artifact, including commit and selected path tree.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "repositoryUrl": "https://github.com/octocat/Hello-World",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation-lab/github-repository-to-llm-context-gitingest").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "repositoryUrl": "https://github.com/octocat/Hello-World",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("automation-lab/github-repository-to-llm-context-gitingest").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "repositoryUrl": "https://github.com/octocat/Hello-World",
  "maxItems": 10
}' |
apify call automation-lab/github-repository-to-llm-context-gitingest --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,automation-lab/github-repository-to-llm-context-gitingest"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LazL34xU8ZeOUqnrT/builds/mRQID0NRd542RMeEx/openapi.json
