codespace-port-visibility
Automate Codespace port visibility via CLI w/ vscode token.
Skill by gitricko
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-port-visibility
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.
About
Reviews
Write a reviewNo 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. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/codespace-port-visibility
What's inside
- Skill name
codespace-port-visibility- Description
- Automate Codespace port visibility via CLI w/ vscode token.
- License
- MIT
- Instructions
- 94 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (5)
- SKILL.md
- export_codespace_token.sh · scripts/
- expose_port.py · scripts/
- get_codespace_token.py · scripts/
- set_port_visibility.py · scripts/
SKILL.md (first lines)
# Codespace Port Visibility Automation
## Problem
GitHub Codespaces require manual UI interaction to change port visibility (public/private/org). This breaks automation for services that need specific port visibility configurations.
## Solution
Extract `GITHUB_TOKEN` from the vscode-server process environment (not shell env), then use `gh codespace ports visibility` CLI.
## Usage
```bash
# Make port public
python3 scripts/set_port_visibility.py 8899 public
# Make port private
python3 scripts/set_port_visibility.py 4387 private
# List all ports
python3 scripts/set_port_visibility.py list
# Or use the CLI directly after sourcing token
source scripts/export_codespace_token.sh
gh codespace ports visibility 8080:public -c $CODESPACE_NAME
```
## NEW Port Exposure (zero manual clicks)
To expose a port that VS Code has **NOT** auto-forwarded yet (e.g. a fresh nginx slot), two steps are required:
```bash
# Step 1: Establish the tunnel (forward to a DIFFERENT local port to avoid bind conflict
# with the service already listening on <port>). gh tries to bind the local side, so if
# nginx already holds 8081, forward 8081:18081 instead.
gh codespace ports forward 8081:18081 -c $CODESPACE_NAME
# Step 2: Flip visibility to public
gh codespace ports visibility 8081:public -c $CODESPACE_NAME
```
**Why:** `gh codespace ports visibility` alone returns `404` for a port GitHub's backend
doesn't yet know about. The `forward` command registers the tunnel; `visibility` then works.
Already-forwarded ports (like 8080, auto-detected by VS Code) only need the `visibility` step.
**Script wrapper:** `scripts/expose_port.py <port> [local-port] [codespace]` does both steps.
## Scripts
| Script | Purpose |
|--------|---------|
| `scripts/set_port_visibility.py` | Main CLI: `python3 set_port_visibility.py <port> <visibility> [codespace]` |
| `scripts/expose_port.py` | NEW: forward + make public in one call (for un-forwarded ports) |
| `scripts/export_codespace_token.sh` | Exports GITHUB_TOKEN for direct `gh` usage |
| `scripts/get_codespace_token.py` | Reusable token extraction module |
## Token Extraction Logic
```python
def get_codespace_token():
# Find code-server process (PID 399 typically)
for pid in /proc/*/cmdline:
if b'code-server' in open(pid, 'rb').read():
with open(f'/proc/{pid}/environ', 'rb') as f:
for entry in f.read().split(b'\x00'):
if entry.startswith(b'GITHUB_TOKEN='):
return entry.decode().split('=', 1)[1]
```
## Integration Example
```bash
# 1. Make service port private for security
python3 scripts/set_port_visibility.py 4387 private
# 2. Make proxy port public for access
python3 scripts/set_port_visibility.py 8080 public
# 3. Start services
LAVISH_AXI_NO_OPEN=1 node dist/cli.mjs sample.html --no-open &
sudo nginx -g 'daemon off;' &
```
## Prerequisites
- `gh` CLI installed (`pnpm add -g @github/cli` or `apt install gh`)
- Running in a GitHub Codespace (vscode-server process exists)
- `CODESPACE_NAME` environment variable set (auto-set in Codespaces)
## Related Skills
- `codespace-gh-auth` — GitHub auth setup for Codespaces
- `github-codespace` — Full Codespace workflow (auth, CI, PR)From gitricko/.minions, MIT.
More from gitricko/.minions
- 0.586score
ci-lint-check
gitricko
Run pre-commit CI lint validation locally before pushing to avoid GitHub Actions failures.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
minions-llm-proxy-ops
gitricko
Use when operating or debugging the .minions LLM proxies.
SkillAFreshness: A★ 1Claude Code +9 - 0.583score
ci-debugging
gitricko
Use when a CI/test failure seems to have one cause but the real root is different, or when a silent failure hides the real issue.
SkillAFreshness: A★ 1Claude Code +9 - 0.580score
docker-test-shell
gitricko
Use when testing in a clean throwaway container.
SkillAFreshness: A★ 1Claude Code +9 - 0.579score
codespace-gh-auth
gitricko
Extract GitHub token from VS Code for API in Codespaces.
SkillAFreshness: A★ 1Claude Code +9 - 0.578score
adopting-external-skills
gitricko
Import external skills into the Codespace tree, adapted.
SkillAFreshness: A★ 1Claude Code +9 - 0.574score
minions-9router-models
gitricko
Manage 9Router model list via etc/9router-models.json.
SkillAFreshness: A★ 1Claude Code +9 - 0.549score
codespace-webtop
gitricko
Native Selkies/XFCE webtop (browser desktop) via pixelflux-based selkies package — install, run, and autostart on any Ubuntu base system
SkillBFreshness: B★ 1Claude Code +9 - 0.547score
ci-log-capture
gitricko
Use when test scripts redirect probe output to /dev/null, hiding failure details.
SkillBFreshness: B★ 1Claude Code +9 - 0.546score
codespace-vscode-open
gitricko
Auto-discover VS Code CLI in Codespaces and open files in connected editor
SkillBFreshness: B★ 1Claude Code +9 - 0.546score
agent-context-transfer
gitricko
Transfer implementation context to a fresh agent for seamless handoff
SkillBFreshness: B★ 1Claude Code +9 - 0.546score
codespace-lavish
gitricko
Launch a headed Lavish-AXI whiteboard over noVNC in Codespaces.
SkillBFreshness: B★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 2
- Open issues
- 3
- Last commit (this folder)
- Oct 13, 2026 (16 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/gitricko/.minions
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from gitricko
- 0.586score
ci-lint-check
gitricko
Run pre-commit CI lint validation locally before pushing to avoid GitHub Actions failures.
SkillAFreshness: A★ 1Claude Code +9 - 0.584score
minions-llm-proxy-ops
gitricko
Use when operating or debugging the .minions LLM proxies.
SkillAFreshness: A★ 1Claude Code +9 - 0.583score
ci-debugging
gitricko
Use when a CI/test failure seems to have one cause but the real root is different, or when a silent failure hides the real issue.
SkillAFreshness: A★ 1Claude Code +9 - 0.580score
docker-test-shell
gitricko
Use when testing in a clean throwaway container.
SkillAFreshness: A★ 1Claude Code +9 - 0.579score
codespace-gh-auth
gitricko
Extract GitHub token from VS Code for API in Codespaces.
SkillAFreshness: A★ 1Claude Code +9 - 0.578score
adopting-external-skills
gitricko
Import external skills into the Codespace tree, adapted.
SkillAFreshness: A★ 1Claude Code +9
Cite this page
codespace-port-visibility skill. Agent Mart. https://agentmart.dev/skills/gitricko-codespace-port-visibility (last updated 2026-10-24)