본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)33k · #8870

pb-api-rules

하는 일

이 스킬은 PocketBase 데이터베이스에서 누가 데이터를 읽고 바꿀 수 있는지 제어하는 방법을 설명합니다. 권한을 올바르게 설정해야 하는 PocketBase 앱 개발자에게 맞습니다.

사용하는 경우

  • ✓레코드를 목록으로 보거나, 보거나, 생성, 수정, 삭제할 수 있는 사람을 정해야 할 때.
  • ✓앱이 403이나 404 응답을 반환해 원인이 되는 규칙을 찾아야 할 때.
  • ✓특정 조건에 맞는 레코드를 찾는 필터를 작성해야 할 때.

스킬 링크

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/pocketbase/pb-api-rules/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/pocketbase/pb-api-rules/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“사용자가 자신의 글만 보고 수정할 수 있도록 PocketBase 규칙을 설정하도록 도와주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 다섯 가지 규칙 유형 각각에 대해 PocketBase 연산자와 매크로를 사용한 필터 식을 작성하고, 각 규칙이 어떤 요청을 제어하는지 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

PocketBase API Rules & Filter Expressions

Rule Types

Each collection has 5 rule types. Each rule is a filter expression that must evaluate to true for the request to proceed.

Rule Controls Locked = Empty string =
List GET /api/collections/{name}/records superusers only everyone can list
View GET /api/collections/{name}/records/{id} superusers only everyone can view
Create POST /api/collections/{name}/records superusers only everyone can create
Update PATCH /api/collections/{name}/records/{id} superusers only everyone can update
Delete DELETE /api/collections/{name}/records/{id} superusers only everyone can delete

Critical: null/locked means only superusers can perform the action (regular users and guests are denied). Empty string "" means EVERYONE including guests. Superusers always bypass API rules entirely — see below.

Superuser Bypass

Superusers (formerly admins) always bypass API rules. Rules only apply to regular auth records and guests.

Filter Syntax

Operators

Operator Meaning Example
= Equal status = "active"
!= Not equal status != "draft"
> Greater than count > 5
>= Greater or equal count >= 5
< Less than count < 10
<= Less or equal count <= 10
~ LIKE (contains) title ~ "hello"
!~ NOT LIKE title !~ "spam"
?= Any/has (array contains) tags ?= "TAG_ID"
?!= None (array not contains) tags ?!= "TAG_ID"
?> Any greater than scores ?> 90
?>= Any greater or equal scores ?>= 90
?< Any less than scores ?< 10
?<= Any less or equal scores ?<= 10
?~ Any LIKE emails ?~ "@gmail.com"
?!~ Any NOT LIKE emails ?!~ "@test.com"

Critical: use ?= (not =) for multi-valued fields (multi-select, multi-relation, multi-file). = checks the raw JSON string, ?= checks individual values.

Logical Operators

status = "active" && author = @request.auth.id
status = "active" || status = "featured"

Parentheses for grouping: (a = 1 || b = 2) && c = 3

Values

  • Strings: "value" or 'value'
  • Numbers: 123, 45.67
  • Booleans: true, false
  • null — empty/missing value
  • Identifiers: field names, macros

Request Macros (@request.*)

Access the current request context in rules:

Macro Type Description
@request.auth.id string Current auth record ID (empty if guest)
@request.auth.email string Current auth record email
@request.auth.verified bool Whether email is verified
@request.auth.collectionId string Auth collection ID
@request.auth.collectionName string Auth collection name
@request.auth.* any Any field from the auth record
@request.body.fieldName any Field value from request body
@request.query.paramName string URL query parameter
@request.headers.name string Request header (lowercase key)
@request.method string HTTP method (GET/POST/PATCH/DELETE)

Auth record relations

You can traverse relations on the auth record:

@request.auth.team.owner = @request.auth.id

Collection Macros (@collection.*)

Cross-collection lookups without explicit joins:

@collection.memberships.user ?= @request.auth.id &&
@collection.memberships.team ?= team

This checks if a record exists in the memberships collection where the user matches the current auth user and the team matches the current record's team field.

Note: @collection.* performs an implicit EXISTS subquery. It's powerful but can be slow on large datasets — add indexes.

Field Modifiers

Use in create/update rules to validate specific field behaviors:

Modifier Works on Description
:isset @request.body.* True if the field was sent in the request (even if empty)
:changed record field True if the field value differs from current stored value (update only)
:length string/array Returns the length
:each array Applies the condition to each element
:lower string Lowercased value

Examples

// Only allow changing status if user is owner
status:changed = false || 
자주 묻는 질문

잠긴 규칙은 무엇을 뜻하나요?

잠긴 규칙은 슈퍼유저만 그 작업을 할 수 있다는 뜻이고, 빈 규칙은 게스트를 포함한 모든 사람이 할 수 있다는 뜻입니다.

슈퍼유저도 규칙을 따르나요?

아니요. 슈퍼유저는 항상 API 규칙을 우회합니다.

필터에 대해 무엇을 다루나요?

필터 문법, 연산자, 매크로, 필드 수정자를 다룹니다.

상세 정보

작성자의 원본 설명

API rules and filter expressions for PocketBase access control. Use when setting permissions, writing filter expressions, configuring who can access what, or debugging 403/404 responses. Covers all 5 rule types, filter syntax, operators, request/collection macros, and field modifiers.

repo: davila7/claude-code-templates

인기도

GitHub 스타
33k
순위
#8870
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬