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

new-resolver

Skill0 starsChanged 8 months agoMITView on GitHub

Scaffold a new GraphQL Yoga resolver with Drizzle ORM query. Use when the user asks to create a GraphQL query, mutation, resolver, or any server-side data operation.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always protect with requireUserSession(event) unless explicitly public

    line 11
  2. Very specific:

    Always use Drizzle returning() after insert/update instead of a second select

    line 12
  3. Distinctive:

    Ask: what domain/entity? What operations are needed (CRUD or specific)?

    line 91
  4. Very specific:

    Check server/db/schema/ for the existing Drizzle table definition

    line 92

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

Rules

  • Resolvers live in server/graphql/resolvers/[domain].ts
  • Types are inferred from Drizzle — never redefined manually
  • Always protect with requireUserSession(event) unless explicitly public
  • Always use Drizzle returning() after insert/update instead of a second select
  • Handle errors with typed throws
  • Export a resolver map object, imported and merged in server/api/graphql.ts

Resolver Template

// server/graphql/resolvers/[domain].ts
import { db } from '../db'
import { [table] } from '../db/schema/[domain]'
import { eq, desc } from 'drizzle-orm'
import type { [Type], New[Type] } from '../db/schema/[domain]'
import type { H3Event } from 'h3'

interface Context {
  event: H3Event
  user?: { id: string }
}

export const [domain]Resolvers = {
  Query: {
    get[Type]: async (_: unknown, { id }: { id: string }, ctx: Context): Promise<[Type]> => {
      await requireUserSession(ctx.event)
      const result = await db
        .select()
        .from([table])
        .where(eq([table].id, id))
        .limit(1)
      if (!result[0]) throw new Error('[Type] not found')
      return result[0]
    },

    list[Type]s: async (_: unknown, _args: unknown, ctx: Context): Promise<[Type][]> => {
      await requireUserSession(ctx.event)
      return db.select().from([table]).orderBy(desc([table].createdAt))
    },
  },

  Mutation: {
    create[Type]: async (
      _: unknown,
      { input }: { input: New[Type] },
      ctx: Context
    ): Promise<[Type]> => {
      await requireUserSession(ctx.event)
      const result = await db.insert([table]).values(input).returning()
      return result[0]
    },

    update[Type]: async (
      _: unknown,
      { id, input }: { id: string; input: Partial<New[Type]> },
      ctx: Context
    ): Promise<[Type]> => {
      await requireUserSession(ctx.event)
      const result = await db
        .update([table])
        .set({ ...input, updatedAt: new Date() })
        .where(eq([table].id, id))
        .returning()
      if (!result[0]) throw new Error('[Type] not found')
      return result[0]
    },

    delete[Type]: async (
      _: unknown,
      { id }: { id: string },
      ctx: Context
    ): Promise<boolean> => {
      await requireUserSession(ctx.event)
      const result = await db.delete([table]).where(eq([table].id, id)).returning()
      return result.length > 0
    },
  },
}

Steps

  1. Ask: what domain/entity? What operations are needed (CRUD or specific)?
  2. Check server/db/schema/ for the existing Drizzle table definition
  3. Generate resolver following the template
  4. Remind: also add corresponding GraphQL type definitions in server/graphql/schema/
  5. Remind: merge resolver into the root resolver in server/api/graphql.ts
  6. Remind: run npm run codegen to regenerate types

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.