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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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.
인기도
- GitHub 스타
- 33k
- 순위
- #8870
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
owasp-security
33k웹 앱, API, 모바일, 컨테이너, AI 에이전트를 위한 OWASP 보안 지침을 따르도록 해서, 흔한 약점을 찾고 수정안을 제안하게 합니다.
agent-management
33k에이전트가 AI Maestro 명령줄을 사용해 AI 에이전트를 만들고, 나열하고, 일시 정지하고, 깨우고, 이름을 바꾸고, 삭제하도록 돕습니다.
agent-messaging
33k에이전트가 Agent Messaging Protocol로 AI 에이전트 사이에 서명된 메시지를 보내고, 받고, 답하도록 돕습니다. 대부분 내 컴퓨터에서 작동합니다.
docs-search
33k에이전트가 자동 생성된 코드 문서에서 함수 시그니처, 클래스 정의, 주석을 검색하도록 해서, 코드를 바꾸기 전에 실제 API를 확인하게 합니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.