This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
yarn- Install all dependencies for all workspacesyarn web- Start web development serveryarn web-prod- Build and serve web app in production modeyarn extension- Start extension development serveryarn extension-build- Build extension for production
- Web workspace:
yarn lint,yarn test(Jest),yarn prettier,yarn build - Extension workspace:
yarn lint,yarn prettier,yarn zip(build and package) - Apps workspace: Jest tests available
MinusX is organized as a yarn workspace monorepo with 3 main packages:
web/- React frontend application with Redux state managementextension/- Chrome extension with content scripts and background workersapps/- Platform-specific integrations, currently focused on Metabase
- Base class
AppControllerinapps/src/base/appController.tsprovides common functionality MetabaseAppControllerextends this base for Metabase-specific functionality- Uses decorator pattern with
@Actionfor exposing methods to the planner - Metabase app defines its own state types, fingerprinting, and query selectors
- Uses
simplePlanstrategy for AI planning and action execution plannerActions.tshandles action execution and tool calling- Redux middleware listens for user messages and triggers planning loops
- Actions are performed via
performActions()which calls app controller methods
- Web: Redux with RTK, persisted state, separate reducers for auth, chat, settings, etc.
- Apps: Zustand for lightweight state management in app-specific contexts
- Extension: Chrome storage APIs for extension-specific data
- Cross-Boundary Pattern: Apps expose Zustand stores via
useStore()that web components can subscribe to usinggetApp().useStore(), enabling reactive UI updates without tight coupling
- RPC System: Bidirectional communication between web app, extension, and content scripts
- Message Passing: Chrome extension APIs for background/content script communication
- Event System: Custom event dispatching for DOM interactions and state updates
- Host Page Monitoring: Apps use
subscribe()pattern to listen for DOM changes in the host page (e.g., Metabase), storing state updates in apps-side Zustand stores that web components subscribe to viagetApp().useStore()
- Full SQL query execution and dashboard interaction capabilities
- Database schema introspection and table cataloging
- Parameter handling for templated queries and dashboard filters
- Semantic layer integration for business context
- Controller located at
apps/src/metabase/appController.ts - State management in
apps/src/metabase/appState.ts
- Content Scripts: Injected into Metabase for DOM manipulation
- Background Scripts: Service worker for cross-tab communication and API calls
- Popup: User interface for quick actions and settings
- Manifest V3: Modern Chrome extension architecture with proper permissions
- Node.js and Yarn for package management
- Chrome Developer Mode for extension loading
- Dev vs Prod Detection: Use
configs.IS_DEVfromweb/src/constants.ts - Environment Files:
.env.developmentand.env.productionfiles per workspace, withenv.defaults.jsonas fallback - Cross-workspace Imports: Apps and web can import from each other using workspace names
- Package Exports: Check
web/src/package.tsandapps/src/package.tsfor current available exports - Settings Access:
web/src/app/appSettings.tsexposes a curated subset of Redux settings to apps workspace viaRPCs.getAppSettings()
- CRITICAL - Redux State Migrations: ANY change to Redux reducer state structure MUST include a corresponding migration in
web/src/state/store.ts. This is non-negotiable - missing migrations cause production crashes for existing users with persisted state. Always increment the version number and add migration logic to initialize new fields. - Concurrency Control: Batch API calls to prevent resource exhaustion when fetching data for multiple entities
- Settings Pattern: New settings require updates in reducer, settings UI, and
appSettings.tsfor cross-workspace access - Code Reuse: When implementing similar logic in multiple places, extract reusable functions to shared modules rather than duplicating code
- Template Tag Handling: Metabase template tags (model references like
{{#1-model_name}}and snippets like{{snippet: name}}) require proper template tag definitions in thedataset_query.native.template-tagsobject to avoid "missing required parameters" errors when generating URLs
- Metabase controller:
apps/src/metabase/appController.ts - Metabase state:
apps/src/metabase/appState.ts - Planner configurations:
web/src/planner/ - Extension manifest:
extension/src/manifest.json - Environment config:
web/src/constants.ts - Package exports:
web/src/package.ts,apps/src/package.ts