스킬 api-organization
🔗

api-organization

안전 ⚙️ 외부 명령어🌐 네트워크 접근🔑 환경 변수📁 파일 시스템 액세스

使用 5 檔案模式組織 API

API 程式碼在程式碼庫中會變得分散且不一致。此技能提供標準化的 5 檔案模式來組織 API 端點、類型和客戶端,具備完整的 TypeScript 類型安全和基於角色的存取控制。

지원: Claude Codex Code(CC)
📊 70 적절함
1

스킬 ZIP 다운로드

2

Claude에서 업로드

설정 → 기능 → 스킬 → 스킬 업로드로 이동

3

토글을 켜고 사용 시작

테스트해 보기

"api-organization" 사용 중입니다. How do I organize API endpoints for a new 'expenses' feature?

예상 결과:

  • 在 src/lib/api/ 中建立這些檔案:
  • • endpoint-types.ts - 定義 Expense 和 CreateExpenseDto 類型,新增到 EndpointParams/Responses/Bodies 介面
  • • endpoints.ts - 新增 expenses: { list, get, create, update, delete } 函式以傳回 URL
  • • api-client.ts - 使用 getAuthHeaders() 自動擷取 Supabase 權杖
  • • admin-api-client.ts - 新增 checkAdminPermission() 以進行管理員專屬操作
  • • protected-endpoints.ts - 匯出 api.expenses 物件,包含類型安全的包裝函式

보안 감사

안전
v5 • 1/16/2026

Pure documentation skill containing only markdown files with architectural guidance. All static findings are false positives triggered by code examples in documentation blocks. No executable code, network calls, file system access beyond its own files, or code execution capabilities exist. The backticks, environment variable references, and URLs detected are documentation examples, not actual shell commands, credential access, or network requests.

5
스캔된 파일
1,502
분석된 줄 수
4
발견 사항
5
총 감사 수

위험 요인

⚙️ 외부 명령어 (235)
references/endpoint-types-pattern.md:3 references/endpoint-types-pattern.md:7-112 references/endpoint-types-pattern.md:112-117 references/endpoint-types-pattern.md:117-118 references/endpoint-types-pattern.md:118 references/endpoint-types-pattern.md:118-119 references/endpoint-types-pattern.md:119-122 references/endpoint-types-pattern.md:122-123 references/endpoint-types-pattern.md:123-124 references/endpoint-types-pattern.md:124 references/endpoint-types-pattern.md:124-127 references/endpoint-types-pattern.md:127-128 references/endpoint-types-pattern.md:128-129 references/endpoint-types-pattern.md:129-143 references/endpoint-types-pattern.md:143-184 references/endpoint-types-pattern.md:184-188 references/endpoint-types-pattern.md:188-197 references/endpoint-types-pattern.md:197-201 references/endpoint-types-pattern.md:201-209 references/endpoint-types-pattern.md:209-214 references/endpoint-types-pattern.md:214-216 references/endpoint-types-pattern.md:216-219 references/endpoint-types-pattern.md:219-221 references/endpoint-types-pattern.md:221-224 references/endpoint-types-pattern.md:224-226 references/endpoint-types-pattern.md:226-229 references/endpoint-types-pattern.md:229-235 references/endpoint-types-pattern.md:235-240 references/endpoint-types-pattern.md:240-241 references/endpoint-types-pattern.md:241-242 references/endpoint-types-pattern.md:242-243 references/endpoints-pattern.md:3 references/endpoints-pattern.md:7-28 references/endpoints-pattern.md:28-31 references/endpoints-pattern.md:31-34 references/endpoints-pattern.md:34-37 references/endpoints-pattern.md:37-40 references/endpoints-pattern.md:40-49 references/endpoints-pattern.md:49-53 references/endpoints-pattern.md:53-57 references/endpoints-pattern.md:57-61 references/endpoints-pattern.md:61-64 references/endpoints-pattern.md:64-69 references/endpoints-pattern.md:69-70 references/endpoints-pattern.md:70-80 references/endpoints-pattern.md:80-88 references/endpoints-pattern.md:88-90 references/endpoints-pattern.md:90-94 references/endpoints-pattern.md:94-98 references/endpoints-pattern.md:98-102 references/endpoints-pattern.md:102-111 references/endpoints-pattern.md:111-115 references/endpoints-pattern.md:115-117 references/endpoints-pattern.md:117-123 references/endpoints-pattern.md:123-124 references/endpoints-pattern.md:124-125 references/endpoints-pattern.md:125-126 references/endpoints-pattern.md:126-127 references/endpoints-pattern.md:127-128 references/endpoints-pattern.md:128-129 references/endpoints-pattern.md:129 references/endpoints-pattern.md:129 references/endpoints-pattern.md:129-133 references/endpoints-pattern.md:133-135 references/endpoints-pattern.md:135-136 references/endpoints-pattern.md:136-138 references/endpoints-pattern.md:138-139 references/endpoints-pattern.md:139-141 references/endpoints-pattern.md:141-146 references/endpoints-pattern.md:146-148 references/endpoints-pattern.md:148-149 references/endpoints-pattern.md:149-150 references/endpoints-pattern.md:150-151 references/endpoints-pattern.md:151-152 references/endpoints-pattern.md:152-154 references/endpoints-pattern.md:154-157 references/endpoints-pattern.md:157-160 references/endpoints-pattern.md:160-161 references/endpoints-pattern.md:161-163 references/endpoints-pattern.md:163-166 references/endpoints-pattern.md:166-169 references/endpoints-pattern.md:169-173 references/endpoints-pattern.md:173-179 references/endpoints-pattern.md:179-181 references/endpoints-pattern.md:181-184 references/endpoints-pattern.md:184-187 references/endpoints-pattern.md:187-190 references/endpoints-pattern.md:190-191 references/endpoints-pattern.md:191-192 references/endpoints-pattern.md:192-194 references/endpoints-pattern.md:194-197 references/endpoints-pattern.md:197-200 references/endpoints-pattern.md:200-204 references/endpoints-pattern.md:204-206 references/endpoints-pattern.md:206-210 references/endpoints-pattern.md:210-211 references/endpoints-pattern.md:211-213 references/endpoints-pattern.md:213-216 references/endpoints-pattern.md:216-218 references/endpoints-pattern.md:218-223 references/endpoints-pattern.md:223-237 references/endpoints-pattern.md:237-240 references/endpoints-pattern.md:240-252 references/endpoints-pattern.md:252-262 references/endpoints-pattern.md:262-269 references/endpoints-pattern.md:269-272 references/endpoints-pattern.md:272-274 references/supabase-auth-integration.md:7 references/supabase-auth-integration.md:9-14 references/supabase-auth-integration.md:14-17 references/supabase-auth-integration.md:17-26 references/supabase-auth-integration.md:26-28 references/supabase-auth-integration.md:28-31 references/supabase-auth-integration.md:31-58 references/supabase-auth-integration.md:58-63 references/supabase-auth-integration.md:63-91 references/supabase-auth-integration.md:91-93 references/supabase-auth-integration.md:93-97 references/supabase-auth-integration.md:97-99 references/supabase-auth-integration.md:99-113 references/supabase-auth-integration.md:113-121 references/supabase-auth-integration.md:121-123 references/supabase-auth-integration.md:123-140 references/supabase-auth-integration.md:140-143 references/supabase-auth-integration.md:143-154 references/supabase-auth-integration.md:154-156 references/supabase-auth-integration.md:156-193 references/supabase-auth-integration.md:193-198 references/supabase-auth-integration.md:198-200 references/supabase-auth-integration.md:200-206 references/supabase-auth-integration.md:206-207 references/supabase-auth-integration.md:207-215 references/supabase-auth-integration.md:215-227 references/supabase-auth-integration.md:227-230 references/supabase-auth-integration.md:230-237 references/supabase-auth-integration.md:237-239 references/supabase-auth-integration.md:239-249 references/supabase-auth-integration.md:249-253 references/supabase-auth-integration.md:253-275 references/supabase-auth-integration.md:275-280 references/supabase-auth-integration.md:280-289 references/supabase-auth-integration.md:289-292 references/supabase-auth-integration.md:292-305 references/supabase-auth-integration.md:305-308 references/supabase-auth-integration.md:308-325 references/supabase-auth-integration.md:325-328 references/supabase-auth-integration.md:328-343 references/supabase-auth-integration.md:343-348 references/supabase-auth-integration.md:348-360 references/supabase-auth-integration.md:360-363 references/supabase-auth-integration.md:363-372 SKILL.md:22 SKILL.md:30 SKILL.md:32-39 SKILL.md:39-49 SKILL.md:49-57 SKILL.md:57-65 SKILL.md:65-73 SKILL.md:73-78 SKILL.md:78-81 SKILL.md:81-88 SKILL.md:88-93 SKILL.md:93-99 SKILL.md:99 SKILL.md:99-102 SKILL.md:102-107 SKILL.md:107-108 SKILL.md:108-113 SKILL.md:113-116 SKILL.md:116-117 SKILL.md:117-125 SKILL.md:125-128 SKILL.md:128-129 SKILL.md:129 SKILL.md:129-130 SKILL.md:130 SKILL.md:130-140 SKILL.md:140-189 SKILL.md:189-193 SKILL.md:193-198 SKILL.md:198-199 SKILL.md:199-200 SKILL.md:200-201 SKILL.md:201-202 SKILL.md:202-205 SKILL.md:205-209 SKILL.md:209-247 SKILL.md:247-251 SKILL.md:251-262 SKILL.md:262-267 SKILL.md:267 SKILL.md:267-268 SKILL.md:268-269 SKILL.md:269-270 SKILL.md:270-271 SKILL.md:271-274 SKILL.md:274-275 SKILL.md:275 SKILL.md:275-282 SKILL.md:282-289 SKILL.md:289-292 SKILL.md:292-293 SKILL.md:293-294 SKILL.md:294-299 SKILL.md:299-301 SKILL.md:301-303 SKILL.md:303-307 SKILL.md:307-313 SKILL.md:313-314 SKILL.md:314-315 SKILL.md:315-320 SKILL.md:320-324 SKILL.md:324 SKILL.md:324-325 SKILL.md:325-332 SKILL.md:332-333 SKILL.md:333-336 SKILL.md:336 SKILL.md:336-337 SKILL.md:337-347 SKILL.md:347-348 SKILL.md:348-349 SKILL.md:349 SKILL.md:349-350 SKILL.md:350-351 SKILL.md:351-354 SKILL.md:354-356 SKILL.md:356-357 SKILL.md:357-364 SKILL.md:364-369 SKILL.md:369-370 SKILL.md:370-371 SKILL.md:371-372 SKILL.md:372-373 SKILL.md:373-374
🌐 네트워크 접근 (7)
🔑 환경 변수 (18)
📁 파일 시스템 액세스 (1)
감사자: claude 감사 이력 보기 →

품질 점수

45
아키텍처
100
유지보수성
81
콘텐츠
20
커뮤니티
100
보안
91
사양 준수

만들 수 있는 것

設定 API 架構

了解在 Next.js 專案中搭配 Supabase auth 使用 5 檔案模式來組織 API 程式碼。

強制執行 API 標準

透過類型安全的模式和基於角色的存取,在團隊中建立一致的 API 結構。

記錄認證流程

了解 Supabase auth 如何與 API 客戶端整合以實現自動認證。

이 프롬프트를 사용해 보세요

新增端點
顯示如何在 endpoint-types.ts 中為新的 'transactions' 網域新增 CRUD 操作的類型。包含參數、回應和主體類型。
定義端點 URL
我應該如何為 'budgets' 資源建構 endpoints.ts?顯示列出、取得、建立、更新和刪除操作的模式。
建立包裝函式
在 protected-endpoints.ts 中為 'categories' 網域建立包裝函式。包含透過 Supabase 的自動認證。
新增管理員存取
如何為 'users' 網域新增管理員專屬端點?顯示帶有角色檢查的 admin-api-client 模式。

모범 사례

  • 在實作端點函式之前先定義所有 TypeScript 類型以確保類型安全
  • 在 api-client 中使用 getAuthHeaders() 來自動擷取 Supabase 存取權杖
  • 在任何管理員專屬 API 操作之前呼叫 checkAdminPermission()
  • 將端點 URL 集中在同一個檔案中以便於維護

피하기

  • 硬編碼 URL 而不是使用 API_ENDPOINTS 常數
  • 跳過類型定義並對 API 回應使用 'any'
  • 直接進行 API 呼叫而不使用 protected-endpoints 包裝函式
  • 在管理員操作之前忘記呼叫 checkAdminPermission()

자주 묻는 질문

此技能是否適用於其他認證提供者?
是的。5 檔案模式是與認證無關的。替換 getAuthHeaders() 以使用您的認證提供者的權杖擷取方式。
支援的最大端點數量是多少?
沒有硬性限制。endpoint-types.ts 中的每個網域都對應到 endpoints.ts。根據需要新增任意數量的網域。
如何與現有的 API 程式碼整合?
將 URL 遷移至 endpoints.ts,在 endpoint-types.ts 中定義類型,將 fetch 呼叫替換為 apiGet/apiPost 包裝函式。
我的 API 資料是否安全儲存?
此模式使用 Supabase httpOnly cookie 和 RLS 政策。安全性取決於正確的 Supabase 配置。
為什麼我的管理員檢查失敗?
確認 users 表格具有正確的角色值。在管理員操作之前呼叫 checkAdminPermission()。檢查使用者工作階段是否存在。
這與標準 fetch 有什麼不同?
此模式為所有 API 呼叫新增了類型安全、集中式認證、基於角色的存取和一致的錯誤處理。

개발자 세부 정보

작성자

BOM-98

라이선스

MIT

참조

main