agentleFS
violacaseviolacase/Nuxt4-test/.claude/skills/new-gql-operation/SKILL.md

new-gql-operation

Skill0 starsChanged 8 months agoMITView on GitHub

Scaffold a GraphQL operation file (.graphql) and trigger codegen. Use when the user asks to write a GraphQL query, mutation, or subscription for use in a Vue component or composable.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 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.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Place alongside the composable that uses them: composables/usePost.graphql

    line 10
  2. Very specific:

    After creating/editing: run npm run codegen to regenerate ~/types/gql.ts

    line 12
  3. Very specific:

    Import the document in the composable: import MyDocument from './myComposable.graphql'

    line 13
  4. Distinctive:

    Use fragments for reused field sets

    line 14
  5. Very specific:

    Ask: what entity, what operations (query/mutation/both)?

    line 101
  6. Very specific:

    Check server/graphql/schema/ to see available fields

    line 102
  7. Distinctive:

    Import the generated types in the composable

    line 105

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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

Skill: New GQL Operation

Rules

  • Operation files use .graphql extension
  • Place alongside the composable that uses them: composables/usePost.graphql
  • Operation name must be unique across the whole codebase (codegen requirement)
  • After creating/editing: run npm run codegen to regenerate ~/types/gql.ts
  • Import the document in the composable: import MyDocument from './myComposable.graphql'
  • Use fragments for reused field sets

Query Template

# composables/use[Type].graphql
query Get[Type]($id: ID!) {
  get[Type](id: $id) {
    id
    # ... fields
    createdAt
    updatedAt
  }
}

query List[Type]s($limit: Int, $offset: Int) {
  list[Type]s(limit: $limit, offset: $offset) {
    id
    # ... fields
  }
}

Mutation Template

# composables/use[Type]Mutations.graphql
mutation Create[Type]($input: Create[Type]Input!) {
  create[Type](input: $input) {
    id
    # ... fields
  }
}

mutation Update[Type]($id: ID!, $input: Update[Type]Input!) {
  update[Type](id: $id, input: $input) {
    id
    # ... fields
  }
}

mutation Delete[Type]($id: ID!) {
  delete[Type](id: $id)
}

Fragment Template (for reuse)

fragment [Type]Fields on [Type] {
  id
  name
  createdAt
  updatedAt
}

query Get[Type]($id: ID!) {
  get[Type](id: $id) {
    ...[Type]Fields
  }
}

Usage in Composable After Codegen

// composables/use[Type].ts
import type { Get[Type]Query, Get[Type]QueryVariables } from '~/types/gql'
import Get[Type]Document from './use[Type].graphql'

export function use[Type](id: MaybeRef<string>) {
  const { data, pending, error, refresh } = useAsyncQuery<Get[Type]Query>(
    Get[Type]Document,
    computed(() => ({ id: unref(id) }) satisfies Get[Type]QueryVariables)
  )

  return {
    [type]: computed(() => data.value?.get[Type] ?? null),
    isLoading: pending,
    error,
    refresh,
  }
}

Steps

  1. Ask: what entity, what operations (query/mutation/both)?
  2. Check server/graphql/schema/ to see available fields
  3. Generate the .graphql file alongside the composable
  4. Run: npm run codegen
  5. Import the generated types in the composable

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.