Cloud Development and AI Rules
GitHub Codespaces: cloud development environments that launch from a repository. Each Codespace: a fresh VM with VS Code (browser or desktop), the repository cloned, dependencies installed, and the development environment configured. For AI rules: the CLAUDE.md is already in the repository and available in the Codespace. But: the AI tools (Claude Code CLI, Copilot extension) need to be installed and configured. The devcontainer: automates this setup so every Codespace starts ready for AI-assisted development.
Why Codespaces matter for AI rules: every developer gets an identical environment. No 'it works on my machine' for AI tool configuration. The devcontainer: defines which AI tools are installed, which extensions are enabled, and which settings are configured. Every Codespace: starts with the same AI tools and the same rules. This consistency: is the cloud development advantage for AI-assisted teams.
The setup: configure the devcontainer to install AI tools, enable AI extensions, and verify the rule file is accessible. The developer: opens a Codespace and starts coding with AI rules active from the first prompt. Zero setup time per Codespace launch.
Step 1: Devcontainer Configuration for AI Tools
The devcontainer.json: defines the Codespace environment. For AI-assisted development, add: Copilot extensions (GitHub.copilot and GitHub.copilot-chat — pre-installed in Codespaces if the user has a Copilot subscription), Cursor-compatible settings (Codespaces use VS Code — Cursor-specific features are not available, but Copilot provides similar AI assistance), and Claude Code CLI (install via a postCreateCommand or Dockerfile feature).
Example devcontainer.json additions: 'customizations': { 'vscode': { 'extensions': ['GitHub.copilot', 'GitHub.copilot-chat'], 'settings': { 'github.copilot.enable': { '*': true } } } }, 'postCreateCommand': 'npm install -g @anthropic-ai/claude-code || true'. The postCreateCommand: installs Claude Code CLI globally. The || true: prevents the Codespace from failing if Claude Code installation fails (the user may not have an Anthropic API key).
Environment variables: for Claude Code (ANTHROPIC_API_KEY) or other API-key-based tools: use Codespaces secrets (Settings → Codespaces → Secrets → New Secret). The secret: injected as an environment variable in every Codespace. The developer: does not need to configure the API key manually. AI rule: 'Store AI tool API keys as Codespaces secrets. Every Codespace: has the key automatically. No manual configuration per Codespace launch.'
Without secrets: every developer configures ANTHROPIC_API_KEY manually in each Codespace. Forgets sometimes. Commits the key accidentally. With Codespaces secrets: the organization admin sets the key once. Every Codespace: has the key injected automatically. No developer action needed. No accidental commits. One configuration: serves every Codespace for every developer.
Step 2: Rule File Access and Verification
The CLAUDE.md (and .cursorrules, .github/copilot-instructions.md): already in the repository. When the Codespace launches: the repo is cloned and the rule files are in the correct locations. No additional mounting or copying needed. The AI tools: read the rule files from the repository root automatically.
Verification script: add a postStartCommand that verifies AI tools and rules are ready. 'postStartCommand': 'node scripts/verify-dev-environment.js'. The script checks: CLAUDE.md exists and is not empty, AI tool CLI is installed (claude --version), API key is configured (ANTHROPIC_API_KEY is set), and the development server starts (optional — verifies the full environment). Output: a summary ('AI environment ready: Claude Code v1.2.3, CLAUDE.md v2.4.0, API key configured.').
Codespace prebuilds: for large repositories, enable Codespace prebuilds. The prebuild: runs postCreateCommand (including AI tool installation) in advance. When a developer opens the Codespace: the environment is already configured. AI tool: already installed. Dependencies: already installed. The developer: starts coding immediately instead of waiting 2-5 minutes for setup. AI rule: 'Prebuilds reduce Codespace launch time from 2-5 minutes to 10-30 seconds. Enable for repositories where AI-assisted development is the primary workflow.'
Without prebuilds: open a Codespace → wait 2-5 minutes for postCreateCommand (npm install, Claude Code install, dependencies). With prebuilds: the environment is pre-built overnight. Open a Codespace → ready in 10-30 seconds. The prebuild: runs the slow setup steps in advance. The developer: gets a ready-to-code environment instantly. For repositories where AI-assisted development is the daily workflow: prebuilds are the highest-impact Codespace optimization.
Step 3: Team Workflow with Codespaces and AI Rules
Onboarding new developers: create a Codespace from the repository. AI tools: installed. Rules: loaded. API key: configured via Codespaces secret. The new developer: starts their first AI-assisted coding session within 5 minutes of joining the team. No local environment setup. No AI tool installation guides. No 'ask Sarah how to configure Claude Code.' The devcontainer: eliminates all setup friction. AI rule: 'Codespaces for onboarding: the new developer's first experience is productive AI-assisted coding, not hours of environment setup.'
Consistent AI behavior: every developer's Codespace has the same AI tools, the same extensions, and the same rules. No developer has a custom local setup that produces different AI behavior. The team's AI output: consistent across all Codespaces. Code reviews: never encounter unexpected patterns because one developer's AI was configured differently. AI rule: 'Codespaces eliminate AI tool configuration drift. Every developer: same tools, same rules, same AI behavior.'
Updating AI tools: when the devcontainer is updated (new AI tool version, new extension, updated postCreateCommand): existing Codespaces are not affected (they use the configuration from when they were created). To update: rebuild the Codespace (Codespaces: Rebuild Container command). New Codespaces: automatically use the updated configuration. AI rule: 'When the devcontainer changes: remind the team to rebuild their Codespaces. Or: use the auto-rebuild setting that rebuilds when devcontainer.json changes on the default branch.'
The devcontainer is updated: new Claude Code version, new extension, new postCreateCommand. Existing Codespaces: still use the old configuration (they were created before the change). The developer: works with outdated tools until they rebuild. Announce devcontainer changes in the team channel: 'Devcontainer updated — rebuild your Codespace to get Claude Code v1.3 and the new Copilot extension.' Or: enable auto-rebuild when devcontainer.json changes on the default branch.
Codespaces AI Rules Summary
Complete Codespaces + AI rules setup.
- Devcontainer: install Copilot extensions, Claude Code CLI via postCreateCommand
- API keys: Codespaces secrets (Settings → Codespaces → Secrets). Auto-injected per Codespace
- Rule files: already in the repo. No additional configuration needed for CLAUDE.md access
- Verification: postStartCommand script verifies tools, rules, and API key on launch
- Prebuilds: pre-install tools and dependencies. Launch in 10-30 seconds instead of 2-5 minutes
- Onboarding: new developer productive in 5 minutes. Zero local setup. AI tools ready from launch
- Consistency: every Codespace has same tools, rules, extensions. No configuration drift
- Updates: rebuild Codespace when devcontainer changes. New Codespaces get updates automatically