agentleFS
OpentronsOpentrons/opentrons/.cursor/skills/documented-mutations/SKILL.md

documented-mutations

Skill525 starsChanged 2 months agoApache-2.0View on GitHub

Migrate react-api-client useMutation hooks to useDocumentedMutation and update app callsites, tests, api-client userNotes, and audit_log keys. Use when converting mutations to documented mutations, wiring documentationState, or adding audit log actions for access control.

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prompt the user for an audit log key and text: Do not invent either. Then add:

    line 16
  2. Very specific:

    Ensure the api-client function accepts/sends userNotes if it does not already.

    line 27
  3. Very specific:

    Keep api-client / useHost mocks.

    line 39
  4. Distinctive:

    Do not add any new test files.

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Documented Mutations

Migrate a useMutation hook to useDocumentedMutation. Copy shape from a migrated example (e.g. react-api-client/src/runs/usePlayRunMutation.ts).

Before coding

Prompt the user for an audit log key and text. Do not invent either. Then add:

  1. Key to AuditLogAction in react-api-client/src/accessControl/types.ts
  2. "key": "text" in app/src/assets/localization/en/audit_log.json only (never zh/)

Hook (react-api-client)

  1. Replace useMutation with useDocumentedMutation from ../accessControl.
  2. Require documentationState: DocumentationState as the first arg.
  3. Pass actionsToDocument as ['audit_log_key'].
  4. Mutation fn must take { variables, userNotes } (DocumentedMutationParameters) and forward userNotes to the api-client call.
  5. Ensure the api-client function accepts/sends userNotes if it does not already.

Callsites (app/)

  • Flex / shared / ODD: pass useDocumentationState() (or an existing docs state).
  • OT-2 only callsites do not need to be updated and should be passed ACCESS_CONTROL_DISABLED_DOCUMENTATION_STATE from app/src/local-resources/access-control/utils.ts.
  • Docs modal cancel: on isDocumentedMutationError, stay on the screen that launched the mutation (confirm modal, wizard step, etc.). Reset any in-flight UI; do not toast, navigate away, or apply mutation success side effects.

Tests — update with proper mocks

  • Hook tests: pass ACCESS_CONTROL_DISABLED_DOCUMENTATION_STATE from react-api-client/src/accessControl/__fixtures__/documentationState.
  • App tests: mock useDocumentationState (or pass the fixture) using ACCESS_CONTROL_DISABLED_DOCUMENTATION_STATE from app/src/local-resources/access-control/__fixtures__/documentationState.
  • Keep api-client / useHost mocks; assert userNotes is forwarded when relevant.
  • Do not add any new test files.

Checklist

  • User supplied audit log key + English text
  • AuditLogAction + en/audit_log.json updated
  • Hook uses useDocumentedMutation + userNotes
  • api-client accepts userNotes
  • Non-OT2 callsites get real docs state; OT2-only get disabled constant
  • Docs cancel restores prior screen with no changes / no user-facing error
  • Hook + app tests updated with proper mocks/fixtures

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.