|
| 1 | +# LLM Context Generator (llm-context) |
| 2 | + |
| 3 | +Generates `~/CLAUDE.md` context file for LLMs (Claude Code, Gemini CLI, etc.) with Workbench workspace information. Claude Code auto-discovers this file on startup. |
| 4 | + |
| 5 | +## Example Usage |
| 6 | + |
| 7 | +```json |
| 8 | +"features": { |
| 9 | + "ghcr.io/verily-src/workbench-app-devcontainers/llm-context:1": { |
| 10 | + "username": "jupyter", |
| 11 | + "userHomeDir": "/home/jupyter" |
| 12 | + } |
| 13 | +} |
| 14 | +``` |
| 15 | + |
| 16 | +Or for local development: |
| 17 | + |
| 18 | +```json |
| 19 | +"features": { |
| 20 | + "./.devcontainer/features/llm-context": { |
| 21 | + "username": "jupyter", |
| 22 | + "userHomeDir": "/home/jupyter" |
| 23 | + } |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +## Options |
| 28 | + |
| 29 | +| Options Id | Description | Type | Default Value | |
| 30 | +|-----|-----|-----|-----| |
| 31 | +| username | Username of the container user | string | root | |
| 32 | +| userHomeDir | Home directory of the container user | string | /root | |
| 33 | + |
| 34 | +## What It Does |
| 35 | + |
| 36 | +When installed, this feature: |
| 37 | + |
| 38 | +1. **Generates `~/CLAUDE.md`** - Claude Code auto-discovers this file on startup |
| 39 | +2. **Provides workspace context** - Name, ID, role, resources, cloud paths |
| 40 | +3. **Includes skill files** - Detailed guides (e.g., custom app creation) in `~/.workbench/skills/` |
| 41 | +4. **Sets up aliases** - `generate-llm-context`, `refresh-context` |
| 42 | + |
| 43 | +## What's in `~/CLAUDE.md` |
| 44 | + |
| 45 | +- **Quick Rules** - When to use this file vs. MCP/CLI |
| 46 | +- **Current Workspace** - Name, ID, description, role, cloud platform |
| 47 | +- **Resource Paths** - JSON lookup for all resources (GCS, BigQuery, etc.) |
| 48 | +- **Data Persistence** - Warning + save commands |
| 49 | +- **Data Exploration** - Common BigQuery/GCS commands |
| 50 | +- **MCP Tools** - Available tools and CLI equivalents |
| 51 | +- **Skills** - Links to detailed guides |
| 52 | + |
| 53 | +## When Context Gets Generated |
| 54 | + |
| 55 | +1. **Automatically on app start** - Via `postStartCommand` (after bucket mounting completes) |
| 56 | +2. **Manually** - Run `generate-llm-context` or `refresh-context` |
| 57 | + |
| 58 | +**Important**: Add the context generation to your `postStartCommand` in `.devcontainer.json`: |
| 59 | + |
| 60 | +```json |
| 61 | +"postStartCommand": [ |
| 62 | + "bash", |
| 63 | + "-c", |
| 64 | + "./startupscript/remount-on-restart.sh jupyter /home/jupyter \"${templateOption:cloud}\" \"${templateOption:login}\" && /opt/llm-context/generate-context.sh /home/jupyter" |
| 65 | +] |
| 66 | +``` |
| 67 | + |
| 68 | +**Note**: Pass the user home directory (e.g., `/home/jupyter`) as an argument because `postStartCommand` runs as root, not as the container user. |
| 69 | + |
| 70 | +This ensures context is generated AFTER authentication and workspace setup complete. |
| 71 | + |
| 72 | +## MCP Integration |
| 73 | + |
| 74 | +This feature works well alongside the `wb-mcp-server` feature: |
| 75 | +- **`llm-context`** provides static context (workspace info, resource paths) |
| 76 | +- **`wb-mcp-server`** provides dynamic tools (search, create, modify) |
| 77 | + |
| 78 | +For optimal LLM experience, use both: |
| 79 | + |
| 80 | +```json |
| 81 | +"features": { |
| 82 | + "./.devcontainer/features/llm-context": {}, |
| 83 | + "./.devcontainer/features/wb-mcp-server": {} |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +## Troubleshooting |
| 88 | + |
| 89 | +### Context not generating? |
| 90 | + |
| 91 | +```bash |
| 92 | +# Check if workspace is set |
| 93 | +wb workspace describe |
| 94 | + |
| 95 | +# If not authenticated: |
| 96 | +wb auth login --mode=APP_DEFAULT_CREDENTIALS |
| 97 | +wb workspace set <workspace-id> |
| 98 | + |
| 99 | +# Then generate manually: |
| 100 | +generate-llm-context |
| 101 | +``` |
| 102 | + |
| 103 | +### Claude Code not seeing context? |
| 104 | + |
| 105 | +```bash |
| 106 | +# Check file exists |
| 107 | +ls -la ~/CLAUDE.md |
| 108 | + |
| 109 | +# Check it's not empty |
| 110 | +head ~/CLAUDE.md |
| 111 | +``` |
| 112 | + |
| 113 | +## File Locations |
| 114 | + |
| 115 | +| File | Purpose | |
| 116 | +|------|---------| |
| 117 | +| `/opt/llm-context/generate-context.sh` | Main generation script | |
| 118 | +| `/opt/llm-context/run-context-generator.sh` | Auto-run wrapper | |
| 119 | +| `~/.workbench/CLAUDE.md` | Generated context (primary) | |
| 120 | +| `~/CLAUDE.md` | Symlink for auto-discovery | |
| 121 | +| `~/.workbench/skills/` | Skill files (e.g., CUSTOM_APP.md) | |
| 122 | + |
| 123 | +## Notes |
| 124 | + |
| 125 | +- This feature requires the Workbench CLI (`wb`) to be installed |
| 126 | +- `jq` is automatically installed if not present |
| 127 | +- Context is only generated if a workspace is set (`wb workspace describe` succeeds) |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +_Note: This feature is automatically configured to work with the `wb-mcp-server` feature if both are installed._ |
0 commit comments