How to Manually Configure a GitHub Token for Private Repositories in Agent-Reach

You can manually configure a GitHub token for private repositories by running agent-reach configure github-token <token> or by editing the ~/.agent-reach/config.yaml file directly to add your github_token value.

When working with private repositories in Agent-Reach, authentication requires a valid GitHub personal access token. This guide explains how to manually configure a GitHub token for private repositories using either the command-line interface or direct file manipulation, based on the actual implementation in the Panniantong/Agent-Reach source code.

Understanding the Configuration Architecture

Agent-Reach persists sensitive configuration data in a YAML file located at ~/.agent-reach/config.yaml. The GitHub token is stored under the github_token key and is accessed via the Config class in agent_reach/config.py. When you execute configuration commands, the CLI handler in agent_reach/cli.py (specifically lines 1122-1124) processes the input and delegates storage to the configuration module.

Method 1: CLI-Based Configuration

The recommended approach uses the built-in configuration command to handle file operations safely.

Generating the Token

First, create a personal access token on GitHub:

  1. Navigate to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic).
  2. Click Generate new token (classic).
  3. Provide a descriptive name (e.g., "Agent-Reach Access").
  4. Select the repo scope to enable private repository access.
  5. Copy the generated token (begins with ghp_).

Setting the Token via CLI

Run the following command to persist the token:

agent-reach configure github-token ghp_YourActualTokenHere

This command invokes config.set("github_token", value) within the CLI handler at agent_reach/cli.py lines 1122-1124, which writes the token to your local configuration file without exposing it in shell history or process lists.

Method 2: Manual File Configuration

For automation scripts or manual control, you can edit the configuration file directly.

Locating the Configuration File

The configuration resides at:

~/.agent-reach/config.yaml

If the directory does not exist, create it:

mkdir -p ~/.agent-reach

Editing the YAML Structure

Open the file in your preferred editor:

nano ~/.agent-reach/config.yaml

Add or modify the github_token entry:

github_token: ghp_YourActualTokenHere

Save the file. Agent-Reach will automatically load this value on the next execution using Config.get("github_token") as implemented in agent_reach/config.py.

Method 3: Programmatic Configuration

You can also configure the token programmatically using Agent-Reach's Python API:

from agent_reach.config import Config

cfg = Config()
cfg.set("github_token", "ghp_YourActualTokenHere")
print("GitHub token configured successfully")

This approach is useful for automation scripts that need to configure Agent-Reach without spawning shell processes.

Verifying Your Configuration

To confirm the token is properly stored, inspect the configuration file:

cat ~/.agent-reach/config.yaml | grep github_token

Expected output:

github_token: ghp_YourActualTokenHere

Alternatively, verify programmatically:

from agent_reach.config import Config
print(Config().get("github_token"))

Summary

  • Agent-Reach stores GitHub tokens in ~/.agent-reach/config.yaml under the github_token key.
  • Use agent-reach configure github-token <token> for secure CLI-based configuration as implemented in agent_reach/cli.py (lines 1122-1124).
  • Edit ~/.agent-reach/config.yaml directly for manual configuration or automation scripts.
  • The Config class in agent_reach/config.py handles all read/write operations for the token storage.

Frequently Asked Questions

Where is the GitHub token stored in Agent-Reach?

The token is stored in the user's home directory at ~/.agent-reach/config.yaml as a YAML key-value pair. This location ensures the token persists across sessions while remaining outside version-controlled directories, as managed by the Config class in agent_reach/config.py.

What GitHub token permissions are required for private repositories?

You need the repo scope for full private repository access. When generating a classic token on GitHub, ensure the repo checkbox is selected. This provides the necessary permissions for Agent-Reach to clone, read, and analyze private repository contents.

Can I configure the token without using the CLI command?

Yes, you can manually create or edit the ~/.agent-reach/config.yaml file in your home directory and add the github_token key directly. This bypasses the CLI interface but achieves the same result as running agent-reach configure github-token, provided the YAML syntax is valid.

How does the token configuration work internally?

The configuration logic is split across two main files: agent_reach/cli.py handles the configure github-token command (specifically around lines 1122-1124), while agent_reach/config.py manages the underlying YAML file operations including the set() and get() methods for the github_token value.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →