Skip to content
Agentmart
Submit a tool

codespace-gh-auth

Extract GitHub token from VS Code for API in Codespaces.

Skill by gitricko

IndexedMIT★ 1
Write a review

Chalk Labs

Need help deploying codespace-gh-auth?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/gitricko-codespace-gh-auth

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Extract GitHub token from VS Code for API in Codespaces.

Use cases: backend, security

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Nov 1, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Shell scripts

Network hosts it talks to 2

  • codeload.github.com · found in install command
  • github.com · found in code

Files it touches

  • ~/.claude/skills/codespace-gh-auth

What's inside

Skill name
codespace-gh-auth
Description
Extract GitHub token from VS Code for API in Codespaces.
License
MIT
Instructions
77 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts
  • Instructions call the network

Agent Skills spec issues

  • body: contains an absolute path from the author's machine

Files (3)

  • SKILL.md
  • git-push-with-token.md · references/
  • codespace-gh-auth.sh · scripts/

SKILL.md (first lines)

# GitHub Codespace Authentication

## Problem
In a GitHub Codespace, the GITHUB_TOKEN env var is set in the VS Code server process but NOT inherited by the Hermes agent session.

## Solution

### Quick Usage (Source the script, then use functions)

```bash
source /home/codespace/.hermes/skills/minions/codespace-gh-auth/scripts/codespace-gh-auth.sh

# Get token for API calls
get_github_token
curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/...

# Push with token-embedded URL (no credential prompts)
git_push_with_token

# Set up gh CLI
setup_gh_cli
gh pr create ...

# Full workflow: commit → push → PR
codespace_create_pr "Title" "Body"
```

### Step 1: Extract the real GITHUB_TOKEN from the VS Code server

```bash
VSCODE_PID=$(pgrep -f "server-main.js" | head -1)
GITHUB_TOKEN=$(cat /proc/$VSCODE_PID/environ 2>/dev/null | tr '\0' '\n' | grep "^GITHUB_TOKEN=" | cut -d= -f2-)
```

### Step 2: Use it for API calls

```bash
curl -s -X POST \
  -H "Authorization: token $GITHUB_TOKEN" \
  -H "Accept: application/vnd.github.v3+json" \
  "https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUM/comments" \
  -d '{"body": "your comment"}'
```

### Step 3: Use it for gh CLI (optional)

```bash
unset GH_TOKEN
export GH_TOKEN="$GITHUB_TOKEN"
gh auth status
```

## Pitfalls
- Do NOT use GITHUB_CODESPACE_TOKEN for REST API calls (returns 401)
- Do NOT run gh auth login (unnecessary)
- The VS Code server PID can be found with: pgrep -f "server-main.js"
- Token is a GitHub App user-to-server token (ghu_xxx prefix), ~40 chars
- **Critical limitation**: This is a GitHub App token gated by Codespaces app installation. It works for the origin repo and Codespaces-connected repos, but FAILS (403) on other repos the user has access to. Use device code flow for those cases.

### Token Scope Comparison

| Method | Token Type | Scope | Works On |
|--------|------------|-------|----------|
| **Extract from VS Code** | GitHub App user-to-server (`ghu_`) | `repo` (app-gated) | Origin repo + Codespaces-connected repos only |
| **Device code flow** | Classic OAuth (`gho_`/`ghp_`) | Full user scopes | **All repos the user has access to** |
| **Unauthenticated API** | None | Public only | Public repos (read-only) |

**When to use device flow instead**: Working on repos outside the Codespaces app installation (other users' repos, orgs without Codespaces app).

## Scripts

- `scripts/codespace-gh-auth.sh` — Reusable functions: `get_github_token`, `git_push_with_token`, `setup_gh_cli`, `codespace_create_pr`

## References

- `references/git-push-with-token.md` — Complete git push + PR workflow using extracted token

From gitricko/.minions, MIT.

More from gitricko/.minions

Signals

Stars
1
Forks
2
Open issues
3
Last commit (this folder)
Oct 13, 2026 (19 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from gitricko

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get codespace-gh-auth running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying codespace-gh-auth?

CallGet help
Cite this page

codespace-gh-auth skill. Agent Mart. https://agentmart.dev/skills/gitricko-codespace-gh-auth (last updated 2026-10-24)