Skip to content

Instantly share code, notes, and snippets.

@MaTriXy
Last active April 13, 2026 13:35
Show Gist options
  • Select an option

  • Save MaTriXy/27658c9c2da9671b75084ffe79948963 to your computer and use it in GitHub Desktop.

Select an option

Save MaTriXy/27658c9c2da9671b75084ffe79948963 to your computer and use it in GitHub Desktop.
Sharing Claude Code Context Files Across a Team (Without Building Anything)
# Sharing Claude Code Context Files Across a Team (Without Building Anything)
## The Problem
You're a small team using Claude Code. Everyone keeps `.md` context files. Some are shared, some are private, and some should only be visible to part of the team. Git alone doesn't handle per-file access control, and Google Drive isn't dev-friendly. You need something in between.
## The Solution: GitHub Org + Teams + Submodules
No middleware. No new service. Just GitHub features you already have.
### 1. Create repos per access tier
```
your-org/context-public # everyone
your-org/context-backend-only # backend team
your-org/context-leads-only # team leads
```
### 2. Set permissions via GitHub Teams
- `everyone` team → read access to `context-public`
- `backend` team → read access to `context-backend-only`
- `leads` team → read access to `context-leads-only`
### 3. Add them as submodules in your main project
```bash
git submodule add git@github.com:your-org/context-public.git .claude/context/public
git submodule add git@github.com:your-org/context-backend-only.git .claude/context/backend
git submodule add git@github.com:your-org/context-leads-only.git .claude/context/leads
```
### 4. Init script for graceful partial access
When a dev doesn't have access to a submodule repo, the clone for that submodule fails — but everything else works fine. The directory just stays empty.
Drop this in your project:
```bash
#!/bin/bash
# init-context.sh — clone what you have access to, skip the rest
for mod in $(git config --file .gitmodules --get-regexp path | awk '{print $2}'); do
git submodule update --init "$mod" 2>/dev/null && \
echo "✓ $mod" || \
echo "✗ $mod (no access, skipping)"
done
```
### 5. Optional: symlinks for convenience
If Claude Code expects `.md` files in specific locations:
```bash
ln -s .claude/context/public/coding-standards.md ./CLAUDE.md
```
A broken symlink (pointing to an empty submodule dir) won't crash anything — the file just won't exist for that dev.
## Why This Works
- **Git submodules are just references** — a URL + commit SHA in `.gitmodules`. The parent repo clones fine even if a dev can't access every submodule.
- **GitHub Teams handle permissions natively** — no custom auth layer needed.
- **Context files are non-critical** — if a `.md` file is missing, Claude Code still works, it just has less context. No build breakage.
- **Updating is standard git** — `cd .claude/context/public && git pull` or `git submodule update --remote`.
## What About Private (Per-Dev) Context?
Add `.claude/context/local/` to `.gitignore`. Each dev keeps their personal context files there. Done.
## TL;DR
| Access Level | Mechanism |
|---|---|
| Public (whole team) | Shared repo, submodule |
| Team-scoped | Separate repo + GitHub Team permissions, submodule |
| Private (per-dev) | `.gitignore`'d local directory |
No middleware required. It's just git.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment