This file provides guidance to Claude Code (claude.ai/code). It helps when working with code in this repository.
This is a browser extension for Chrome and Firefox that colorizes the AWS Management Console. It allows users to assign colors to different AWS session ARNs. This helps differentiate between multiple accounts and roles.
The extension consists of:
- A content script that modifies AWS console pages (header, footer, session selector)
- A popup UI (React-based) for managing color settings per session ARN
- Color settings stored in browser storage (synced across devices)
- Build tool: WXT (WebExtension Tools) - modern framework for building browser extensions
- Runtime: Bun (specified in
.bun-version) - TypeScript: Strict type checking with Zod for runtime validation
- React: Popup UI built with React 19 and react-color-palette
- Testing: Playwright for end-to-end tests
bun install# Chrome extension with live reload
bun run dev:chrome
# Firefox extension with live reload
bun run dev:firefox# Type check (runs before all builds)
bun run compile
# Production builds
bun run build:chrome
bun run build:firefox
# Development build (for testing)
bun run build:chrome:dev# Production ZIPs (outputs to dist/)
bun run zip:chrome
bun run zip:firefox
# Development ZIP
bun run zip:chrome:dev# Run E2E tests (builds dev Chrome extension first)
bun run e2e# Format with Prettier
bunx prettier --write .-
content.ts: Content script injected into AWS console pages- Handles both console pages and session selector pages
- Listens for messages from popup via browser.runtime.onMessage
- Uses MutationObserver to watch for dynamically loaded elements
- Extracts session ARN from
<meta name="awsc-session-data">
-
popup/: Extension popup UIApp.tsx: Main React component managing color settings CRUD- Communicates with content script via browser.tabs.sendMessage
- Uses react-color-palette for color picker
-
color_settings.ts: Storage interface for color settings- Defines Zod schemas for type-safe color settings
- Storage key:
"sync:colorSettings"(synced across devices)
-
lib.ts: Shared utilitiesMessageTypeenum for popup ↔ content script communication- URL matching patterns for AWS console domains
getMatches(): Returns content script match patterns (includes file:// in dev mode)
wxt.config.ts defines:
- Manifest settings (name, permissions)
- Browser-specific configuration
- Development keys for consistent extension IDs during testing
The extension uses two message types between popup and content script:
getSessionARN: Popup requests current session ARN from content scriptchangeColor: Popup notifies content script to refresh colors after settings change
Content script handles two AWS page types:
- Console pages (
*.console.aws.amazon.com): Colors header and footer navigation - Session selector (
*.signin.aws.amazon.com/sessions/selector): Adds color blocks to session cards
- Chrome: Uses
keyfield in manifest for consistent extension ID in development - Firefox: Uses
browser_specific_settings.gecko.idfor development storage access
Runtime validation with Zod ensures color settings from storage match expected schema. All storage reads are validated.
Content script uses MutationObserver pattern when target elements aren't immediately available. This is because AWS console uses dynamic rendering.
Color settings use sync: storage prefix, automatically syncing across user's devices.
End-to-end tests (tests/e2e/) use Playwright with chromium profile. The dev build allows file:// protocol for loading local HTML fixtures.
The project uses GitHub Actions with:
format.yml: autoformatting with Prettierplaywright.yml: end-to-end test executionsuper-linter.yml: Multi-language linting- Security scanning with CodeQL and OSV-Scanner