This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Tako is a browser extension for GitHub that provides a fast inline, expandable file tree with file preview. Built as a Chrome/Firefox WebExtension (Manifest V3) that runs as a content script on github.com repository pages.
# Development with hot reload
pnpm dev
# Production build
pnpm build
# Clean build artifacts
pnpm cleansrc/content.tsxis the content script entry point- Runs on
document_startfor all github.com repo pages - Two main render paths:
renderTokenPrompt()- if no GitHub token storedrenderTako()- main app with authenticated Octokit client
- Uses
github-url-detectionto detect repo tree pages viaisRepoTree() - Listens to
turbo:renderevents to handle GitHub's SPA navigation onElementRemoval()re-initializes if Tako element gets removed
- Zustand store in
src/store.tswith two key states:previewedFile- currently previewed file (opens side panel)hoveredFile- file user is hovering over
- Store subscription in
content.tsxmanipulates GitHub DOM:- Removes
.Layoutclass to break GitHub's layout constraints - Sets
max-width: unseton repo main element - Hides sidebar when file previewed
- Removes
- TanStack Query for all GitHub API calls
- Two main query configs:
repoContentsQueryConfig- fetches directory contents, handles submodules detectionmostRecentRepoCommitQueryConfig- fetches latest commit info
- Prefetches root contents and latest commit before rendering
- Uses Octokit REST client with user's personal access token
Tako.tsx- root component, providesTakoContextwith repository info and Octokit clientContents.tsx- recursively renders directory contents (dirs, files, submodules, symlinks)Preview.tsx- renders file preview (text/images), uses GitHub's markdown API for syntax highlightingItem.tsx- individual file/folder items with expand/collapse for directories- Submodules get their own nested
TakoProviderwith separate repository context
Preview.tsxdetermines file type: text/image/unknown- Text files: fetches blob via
git.getBlob, renders with GitHub markdown API for syntax highlighting - Images: uses GitHub's raw URL (
/owner/repo/blob/ref/path?raw=true) - Markdown: renders as HTML via GitHub API, rewrites relative image URLs
- Line numbers generated client-side for non-markdown text files
getRepository()incontent.tsxextracts owner/repo/branch from URL- Branch comes from URL path (
tree/{branch}) or falls back to default branch - Branch name is URI decoded to handle special characters
- Built with Vite
- TypeScript with React 19
- Uses GitHub Primer CSS classes (extension runs in GitHub DOM context)
- WebExtension Polyfill for cross-browser compatibility
- Stores GitHub token in
chrome.storage.sync - remember to run
pnpm formatafter changing code