Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

keystonejs

БесплатноБез исполняемых скриптовНе проверен

Keystone is an open-source headless CMS and application framework for Node.js that turns a TypeScript schema into a GraphQL API, a Prisma database layer and…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

KeystoneJS — Headless CMS & Application Framework

Overview

Keystone describes your data as TypeScript list() definitions. From that one file it generates a Prisma schema, a GraphQL API (/api/graphql) and an Admin UI. The npm scope is @keystone-6; the current line is @keystone-6/core 8.x (8.1.0 at the time of writing), which moved to Prisma 7 driver adapters, Next.js 16, React 19, Apollo Server 5 and Express 5. Most older tutorials (and db.url, keystone prisma, keystone migrate, storage: at config level, validateInput) describe 6.x/7.x and fail on 8.

Instructions

Install and run

npm create keystone-app@latest acme-news     # starter project
cd acme-news && npm run dev                  # keystone dev

For an existing project, @keystone-6/core now needs these as peer dependencies, installed by you:

npm install @keystone-6/core @keystone-6/auth @keystone-6/fields-document \
  @prisma/client prisma next react react-dom
npm install @prisma/adapter-pg pg                     # PostgreSQL
# or: @prisma/adapter-better-sqlite3 better-sqlite3   # SQLite
# or: @prisma/adapter-mariadb                         # MySQL

The first keystone dev/keystone build creates prisma.config.ts, schema.prisma, schema.graphql and generated/ (types in generated/keystone/types.ts, Prisma client in generated/prisma). Commands: keystone dev (pushes the schema to the database), keystone build, keystone start, keystone postinstall (= build --frozen --no-ui, fails if prisma.config.ts is missing). Set DATABASE_URL for prisma.config.ts too.

Configuration, sessions and auth

db.url is gone. Pass a Prisma driver adapter through prismaClientOptions:

// keystone.ts
import { config } from '@keystone-6/core'
import { statelessSessions } from '@keystone-6/core/session'
import { createAuth } from '@keystone-6/auth'
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3'
import { lists } from './schema'
import { extendGraphqlSchema } from './extensions'
import type { TypeInfo } from './generated/keystone/types'

const { withAuth } = createAuth({
  listKey: 'User',
  identityField: 'email',
  secretField: 'password',
  sessionData: 'id name role',          // copied into session.data on every request
})

export default withAuth<TypeInfo>(
  config<TypeInfo>({
    db: {
      provider: 'sqlite',               // 'postgresql' | 'mysql' | 'sqlite'
      prismaClientOptions: () => ({
        adapter: new PrismaBetterSqlite3({ url: process.env.DATABASE_URL ?? 'file:./keystone.db' }),
      }),
      async onConnect(context) {        // seed the first admin (createAuth has no initFirstItem any more)
        const sudo = context.sudo()
        if ((await sudo.db.User.count()) > 0) return
        await sudo.db.User.createOne({
          data: { name: 'Admin', email: '[email protected]', password: process.env.ADMIN_PASSWORD!, role: 'admin' },
        })
      },
    },
    lists,
    graphql: { extendGraphqlSchema },   // not a top-level key
    session: statelessSessions({
      maxAge: 60 * 60 * 24 * 30,
      secret: process.env.SESSION_SECRET!,   // at least 32 characters
    }),
    ui: { isAccessAllowed: ({ session }) => session?.data?.role === 'admin' },
  })
)

For PostgreSQL use provider: 'postgresql' with new PrismaPg({ connectionString: process.env.DATABASE_URL }) from @prisma/adapter-pg.

Schema, access control and hooks

// schema.ts
import { list } from '@keystone-6/core'
import { allowAll } from '@keystone-6/core/access'
import { text, relationship, timestamp, select, password, integer } from '@keystone-6/core/fields'
import { document } from '@keystone-6/fields-document'
import type { Lists } from './generated/keystone/types'

type Session = { itemId: string; data: { id: string; name: string; role: 'admin' | 'editor' | 'author' } }
const isSignedIn = ({ session }: { session?: Session }) => !!session
const isAdmin = ({ session }: { session?: Session }) => session?.data.role === 'admin'

export const lists = {
  User: list({
    access: { operation: { query: isSignedIn, create: isAdmin, update: isSignedIn, delete: isAdmin } },
    fields: {
      name: text({ validation: { isRequired: true } }),
      email: text({ validation: { isRequired: true }, isIndexed: 'unique' }),
      password: password({ validation: { isRequired: true, length: { min: 10 } } }),
      role: select({
        type: 'enum',
        options: [
          { label: 'Admin', value: 'admin' },
          { label: 'Editor', value: 'editor' },
          { label: 'Author', value: 'author' },
        ],
        defaultValue: 'author',
        access: { update: isAdmin },     // only admins may change roles
      }),
      posts: relationship({ ref: 'Post.author', many: true }),
    },
  }),
  Post: list({
    access: {
      operation: { query: allowAll, create: isSignedIn, update: isSignedIn, delete: isAdmin },
      filter: {
Полный SKILL.md на GitHub

Установить keystonejs в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл keystonejs?

Keystone is an open-source headless CMS and application framework for Node.js that turns a TypeScript schema into a GraphQL API, a Prisma database layer and an Admin UI. Use it to define content schemas, add sessions and role-based access control, write lifecycle hooks, extend the GraphQL API, or upgrade a Keystone 6 project to @keystone-6/core 8 (Prisma 7 adapters, Next 16).

Как установить скилл keystonejs?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл keystonejs запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить keystonejs с