Command Palette

Search for a command to run...

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

strapi

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

Strapi is an open-source headless CMS built on Node.js that turns content types you model in an admin panel into REST and GraphQL APIs, with roles, a media…

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

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

Strapi — Open-Source Headless CMS

Overview

Strapi lets editors manage content in an admin panel while developers consume it through generated REST (and optional GraphQL) endpoints. This skill targets Strapi 5 (5.59 at the time of writing). Version 5 changed the API shape from version 4: entries are documents addressed by a string documentId, responses are flat (no attributes wrapper), publishedAt filtering is replaced by a status parameter, and the Entity Service is deprecated in favor of the Document Service API. Code written for v4 will break.

Instructions

Project setup

npx create-strapi@latest newsroom-cms     # prompts: TypeScript (default), database, example data
cd newsroom-cms
npm run develop                           # admin at http://localhost:1337/admin

Non-interactive: npx create-strapi@latest newsroom-cms --non-interactive --skip-cloud (TypeScript, SQLite, npm dependencies installed). Other flags: --js, --dbclient postgres|mysql|sqlite, --use-pnpm, --no-example. Create the first admin user in the browser on first start. Secrets (APP_KEYS, API_TOKEN_SALT, ADMIN_JWT_SECRET, JWT_SECRET) live in .env; set production values and keep the file out of git. npm run develop is for development (auto-reload, Content-Type Builder enabled); production uses npm run build then npm run start.

Content types

Model them in the Content-Type Builder (development mode only; it writes schema files under src/api/, so commit them):

  • Collection types hold many entries (articles, products); single types hold one (homepage, site settings).
  • Components are reusable field groups (SEO, hero) that you attach to content types or to dynamic zones.
  • Each collection type article gets routes under /api/articles:
Method Path Action
GET /api/articles list
POST /api/articles create (body { "data": { ... } })
GET /api/articles/:documentId read one
PUT /api/articles/:documentId update
DELETE /api/articles/:documentId delete

Single types are /api/homepage (no id). New endpoints are closed: in the admin go to Settings, Users & Permissions, Roles, Public (or Authenticated) and tick find/findOne, or send an API token created under Settings, API Tokens as Authorization: Bearer <token>.

Querying the REST API

const STRAPI_URL = process.env.NEXT_PUBLIC_STRAPI_URL ?? "http://localhost:1337";
const headers = { Authorization: `Bearer ${process.env.STRAPI_API_TOKEN}` };

// Strapi 5: flat documents, published versions by default
export async function getArticles(page = 1, pageSize = 10) {
  const params = new URLSearchParams({
    "populate[0]": "cover",
    "populate[1]": "author",
    sort: "publishedAt:desc",
    "pagination[page]": String(page),
    "pagination[pageSize]": String(pageSize),
  });
  const res = await fetch(`${STRAPI_URL}/api/articles?${params}`, {
    headers,
    next: { revalidate: 60 },
  });
  if (!res.ok) throw new Error(`Strapi responded ${res.status}`);
  const { data, meta } = await res.json();
  // data[i] = { id, documentId, title, slug, publishedAt, cover: {...}, author: {...} }
  return { articles: data, pagination: meta.pagination };
}

export async function getArticleBySlug(slug: string) {
  const params = new URLSearchParams({ "filters[slug][$eq]": slug, populate: "cover" });
  const res = await fetch(`${STRAPI_URL}/api/articles?${params}`, { headers });
  const { data } = await res.json();
  return data[0] ?? null;
}

Rules that differ from v4 and cause most bugs:

  • Relations, media and components are not returned unless populated. Use populate[0]=cover or populate[author][populate][0]=avatar; avoid populate=* in production and populate=deep plugins.
  • Draft and Publish: the REST API returns the published version by default, so no publishedAt filter is needed. Add status=draft to read drafts (needs a token allowed to). A POST or PUT publishes immediately unless you pass status=draft.
  • Filter with filters[field][$eq]=value; other operators include $eqi, $contains, $in, $notNull, $between. Page size is capped by api.rest.maxLimit in config/api.ts.
  • Build complex query strings with the qs library rather than by hand.
  • Fetch from server code or a proxy route, never ship a full-access token in browser bundles.

Custom controllers, routes and the Document Service

Inside Strapi, use strapi.documents(uid) (Document Service) instead of strapi.entityService.

// src/api/article/controllers/article.ts
import { factories } from "@strapi/strapi";

export default factories.createCoreController("api::article.article", ({ strapi }) => ({
  // Custom action: POST /api/articles/:id/views (route below)
  async incrementViews(ctx) {
    const { id: documentId } = ctx.params;
    const article = await strapi.documents("api::article.article").fi
Полный SKILL.md на GitHub

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

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

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

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

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

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

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

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

_scores.json

FAQ

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

Strapi is an open-source headless CMS built on Node.js that turns content types you model in an admin panel into REST and GraphQL APIs, with roles, a media library and plugins. Use when setting up a Strapi 5 project, modeling content types, querying the REST API from a Next.js or other frontend, customizing controllers and routes, or migrating from Strapi 4.

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

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

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

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

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

Сравнить strapi с