[← All Build It! Rules](https://developers.google.com/profile/badges/builder/rules.md.txt)

# Inspector Editing Mode (Session-Scoped)

Rule

Establishes a stateful, session-scoped Inspector Editing Mode for co-maintaining React components and their corresponding isolated development inspectors without cross-session contamination.
Featured in: [Episode 9: Build a hidden edit mode for your AI app with reusable agent skills](https://developers.google.com/profile/badges/builder/videos/video-9.md.txt)

## Sign in to access this rule

Sign in with your Google Developer Profile to view and copy the full rule used in the Build It! series.
<button class="gate-button"> Sign in to view </button>

## Developer Profile Required

You are not eligible for a developer profile. Notify your workspace administrator to [enable this feature](https://developers.google.com/profile/help/faq.md.txt#workspace).

## Create a Developer Profile

Create a free Google Developer Profile to unlock all Build It! skills, rules, prompts, and artifacts.

## Join Builder Central to Unlock

Claim your free Builder member badge in one click to unlock all Build It! skills, rules, prompts, and artifacts.
<button id="unlock_builder_badge" class="gate-button">Start building</button>

## How Session-Scoped Inspector Editing Mode Works

When you iterate on UI components with a Component Inspector open, you want component edits to update the matching inspector view in the same turn, without permanently forcing inspector edits in future sessions. This rule solves that using a conversation-scoped marker file:

- **Default OFF for every new session**: Brand new conversations start in Normal Mode so routine edits touch only the exact files you ask for.
- **Enter Inspector Editing Mode** : Say *"Enter inspector editing mode"* (or *"Turn on inspector mode"* ). The agent creates a session-scoped marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`, reads `src/dev/registry.ts`, and lists every registered component covered for this session.
- **Automatic co-maintenance** : While active, any change you request to a registered component updates the component first and immediately synchronizes its matching `src/dev/inspectors/[ComponentName]Inspector.tsx` using the [Component Inspector Updater](https://developers.google.com/profile/badges/builder/skills/component-inspector-updater.md.txt) workflow, runs `npx tsc --noEmit`, and stamps the response with a confirmation chip.
- **Exit cleanly anytime** : Say *"Exit inspector editing mode"* to remove the marker file and return to normal single-target editing. Turning the mode on in one session never affects parallel or future sessions.

## How to Install in Google Antigravity

Place this rule in your Google Antigravity workspace alongside the two Episode 9 Component Inspector skills:

1. Create the folder `.agents/rules/` in your project workspace (or open Google Antigravity **Customizations \> Rules** to add a workspace rule).
2. Save the full Markdown rule below as `inspector-editing-mode.md` inside `.agents/rules/`.
3. Install the companion skills [Component Inspector Generator](https://developers.google.com/profile/badges/builder/skills/component-inspector-generator.md.txt) and [Component Inspector Updater](https://developers.google.com/profile/badges/builder/skills/component-inspector-updater.md.txt) so your agent has both the scaffolding and synchronization workflows referenced by this rule.

## Inspector Editing Mode Rule Definition

Copy this complete rule definition into your workspace as inspector-editing-mode.md.
inspector-editing-mode.md (.agents/rules/inspector-editing-mode.md)

    # Inspector Editing Mode (Session-Scoped)

    This rule establishes a stateful, session-scoped **Inspector Editing Mode** for co-maintaining React components and their corresponding isolated development inspectors (`src/dev/inspectors/[ComponentName]Inspector.tsx`).

    ---

    ## 1. Scope & Isolation Model

    * **Session-Scoped**: The on/off state of this mode is strictly scoped to the current conversation session (`<conversation-id>`).
    * **Default State**: Every new conversation session begins with Inspector Editing Mode **OFF** by default.
    * **State Marker**:
      - Activation is tracked at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
      - If this file exists for the active session's conversation ID, Inspector Editing Mode is **ON**.
      - If this file does NOT exist, Inspector Editing Mode is **OFF**.
    * **Zero Cross-Session Contamination**: Turning this mode on in one conversation has no effect on any other parallel or future conversation sessions.

    ---

    ## 2. Trigger Commands & State Transitions

    ### A. Entering Inspector Mode
    * **Trigger Phrases**:
      - *"Enter inspector editing mode"*
      - *"Start inspector editing mode"*
      - *"Turn on inspector mode"*
      - *"Inspector mode on"*
    * **Agent Action**:
      1. Create the marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
      2. Read `src/dev/registry.ts` to identify all currently registered components.
      3. Respond confirming:
         - Inspector Editing Mode is now **ACTIVE** for this session.
         - Any subsequent changes to registered components will automatically update both the component and its dev inspector.
         - List the currently registered components covered by this mode.

    ### B. Exiting Inspector Mode
    * **Trigger Phrases**:
      - *"Exit inspector editing mode"*
      - *"Stop inspector editing mode"*
      - *"Turn off inspector mode"*
      - *"Inspector mode off"*
    * **Agent Action**:
      1. Remove the marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active` if present.
      2. Respond confirming that Inspector Editing Mode is now **DEACTIVATED** for this session and normal single-target editing has resumed.

    ### C. Status Query
    * **Trigger Phrases**:
      - *"Is inspector mode active?"*
      - *"Inspector mode status"*
      - *"What mode am I in?"*
    * **Agent Action**:
      - Check for the existence of `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
      - Report whether the current session is in **Inspector Mode** or **Normal Mode**.

    ---

    ## 3. Co-Maintenance Behavior While Mode is ACTIVE

    Whenever the user requests changes, fixes, or refactors to ANY component registered in `src/dev/registry.ts`:

    1. **Step 1: Update the Core Component**
       - Apply the requested code changes, props modifications, or behavioral logic in `src/components/.../[ComponentName].tsx` (or `src/views/.../[ComponentName].tsx`).
       - Update any relevant unit tests in `scripts/` or `__tests__/`.

    2. **Step 2: Automatically Synchronize the Dev Inspector**
       - Locate the matching inspector at `src/dev/inspectors/[ComponentName]Inspector.tsx`.
       - Apply the `component-inspector-updater` workflow:
         - **Props & State**: Reconcile any new, altered, or deleted props into the *Editable State* or *Props State* categories.
         - **Computed State**: Update derived `useMemo` metrics if underlying rules or formulas changed.
         - **Test Verification Cards**: Synchronize the plain-English test fixtures at the bottom of the inspector with the new behavior, updating click handlers so `[Load Test Fixture]` accurately reflects the new state.
         - **Preserve Custom Presets**: Keep all existing scenario presets (e.g. week overhauls, superset pairs, edge cases) intact, adapting their shapes to new prop signatures.
         - **Advance Timestamp Chip**: Advance `const GENERATED_AT = 'YYYY-MM-DD HH:MM [TIMEZONE]';` to the current local timestamp.
         - **No Auto-Scroll**: Ensure all internal scrolling is scoped strictly to element containers (`containerRef.current.scrollTop = containerRef.current.scrollHeight`) with zero page-level scrolling.

    3. **Step 3: Verify Types**
       - Run `npx tsc --noEmit` to ensure type alignment between the component and its inspector.
       - **DO NOT** run raw `npm run build` while a local dev server is active to prevent wiping out `.next/` chunk manifests.

    4. **Step 4: Badge Confirmation in Response**
       - Include an explicit status chip in your response header or summary:
         `[Inspector Mode: Synced <ComponentName> & Dev Inspector]`

    ---

    ## 4. Behavior While Mode is INACTIVE (Default)

    * When the mode is OFF, the agent performs only the exact requested file modifications.
    * Do NOT edit `src/dev/inspectors/` unless the user explicitly requests an inspector update or instructs the agent to create a brand new inspector route.