documented-mutations

Migrate react-api-client useMutation hooks to useDocumentedMutation with audit log integration.

520|209|Updated Jul 6, 2015
One-click install
npx skills add https://github.com/Opentrons/opentrons --skill documented-mutations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: documented-mutations
Source: https://github.com/Opentrons/opentrons/tree/main/.cursor/skills/documented-mutations
Command: npx skills add https://github.com/Opentrons/opentrons --skill documented-mutations

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Converting React Query mutations to documented mutations in the Opentrons codebase requires coordinated changes across react-api-client hooks, app callsites, api-client functions, localization files, and tests, and missing any step breaks access control documentation.

Core Features & Use Cases

  • Hook Migration: Replace useMutation with useDocumentedMutation, wire documentationState, and forward userNotes through the api-client layer.
  • Audit Log Registration: Add new AuditLogAction keys and English localization entries for access control audit trails.
  • Callsite and Test Updates: Apply correct documentation state per platform (Flex, ODD, OT-2) and update hook and app tests with proper fixtures and mocks.
  • Use Case: When adding an audit-logged action like pausing a run, use this Skill to convert the mutation, register the audit log key, update all callsites, and fix the tests in one guided pass.

Quick Start

Migrate the usePauseRunMutation hook to a documented mutation and update its callsites, tests, and audit log entries.

Frequently Asked Questions about documented-mutations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a useMutation hook to useDocumentedMutation?

Replace useMutation with useDocumentedMutation from ../accessControl, require documentationState as the first argument, pass actionsToDocument with your audit log key, and make the mutation function accept { variables, userNotes } and forward userNotes to the api-client call.

How do I add a new audit log action for access control?

Prompt the user for the audit log key and text rather than inventing them. Add the key to AuditLogAction in react-api-client/src/accessControl/types.ts and add the key-text pair to app/src/assets/localization/en/audit_log.json only, never the zh locale.

Do OT-2 callsites need documentation state for documented mutations?

OT-2 only callsites do not need real documentation state. Pass ACCESS_CONTROL_DISABLED_DOCUMENTATION_STATE from app/src/local-resources/access-control/utils.ts, while Flex, shared, and ODD callsites use useDocumentationState.

What should happen when a user cancels the documentation modal?

On isDocumentedMutationError, stay on the screen that launched the mutation such as the confirm modal or wizard step. Reset any in-flight UI without toasting, navigating away, or applying mutation success side effects.

How do I update tests for documented mutations?

Hook tests pass ACCESS_CONTROL_DISABLED_DOCUMENTATION_STATE from the react-api-client fixtures, and app tests mock useDocumentationState using the app fixtures. Keep existing api-client and useHost mocks, assert userNotes forwarding, and do not add new test files.