view-file

robbyt's avatarfrom robbyt

Fetch raw file content from GitHub URLs. Trigger when user shares a GitHub file link (https://github.com/user/repo/blob/main/file.go) and wants to view the source code. Avoids HTML/JS clutter from WebFetch.

⭐31stars🔀0forks📁View on GitHub🕐Updated Dec 20, 2025

When & Why to Use This Skill

The 'view-file' skill is a specialized utility designed to fetch clean, raw source code directly from GitHub URLs. By bypassing the standard web interface, it eliminates HTML and JavaScript clutter, providing Claude with direct access to the underlying code for more accurate analysis, debugging, and review. This tool is essential for developers who need to share specific repository files with an AI agent without the overhead of manual copy-pasting or noisy web scraping.

Use Cases

  • Code Review and Analysis: Seamlessly import specific source files into the conversation for detailed code reviews, security audits, or logic explanations.
  • Debugging and Troubleshooting: Quickly retrieve the contents of specific files mentioned in error logs or bug reports to identify and fix issues efficiently.
  • Technical Documentation Retrieval: Fetch README files, configuration guides, or markdown documentation from repositories to provide context-aware assistance.
  • Learning and Reference: Access example code snippets or library implementations from open-source projects to understand best practices and implementation details.
nameview-file
descriptionFetch raw file content from GitHub URLs. Trigger when user shares a GitHub file link (https://github.com/user/repo/blob/main/file.go) and wants to view the source code. Avoids HTML/JS clutter from WebFetch.

View GitHub Files

Fetch raw file content from GitHub URLs without HTML/JS clutter.

Prerequisites

GitHub CLI must be installed and authenticated:

gh auth status

When to Use

When a user shares a GitHub file URL like:

  • https://github.com/user/repo/blob/main/src/file.go
  • https://github.com/user/repo/tree/v1.0/docs/README.md

Use this skill instead of WebFetch to get clean source code.

Helper Script

python3 scripts/view_github_file.py https://github.com/user/repo/blob/main/path/to/file.go

The script:

  • Parses the GitHub URL to extract owner, repo, ref, and path
  • Uses gh api to fetch file content
  • Decodes base64-encoded response
  • Returns clean source code

Supported URL Formats

https://github.com/{owner}/{repo}/blob/{ref}/{path}
https://github.com/{owner}/{repo}/tree/{ref}/{path}

Where {ref} can be a branch name, tag, or commit SHA.

Fallback (if script fails)

Parse the URL manually and use gh api:

# From URL: https://github.com/golang/go/blob/master/README.md
# Extract: owner=golang, repo=go, ref=master, path=README.md
gh api repos/golang/go/contents/README.md?ref=master --jq '.content' | base64 --decode

Or use raw.githubusercontent.com:

curl https://raw.githubusercontent.com/golang/go/master/README.md