Agent SkillsMelvynx/Parler › org-api-route

org-api-route

GitHub

用于在NowStack中创建或更新基于Better Auth API密钥的组织级公共API路由,涵盖路由开发、API密钥管理UI实现及文档编写。

web-app/.agents/skills/org-api-route/SKILL.md Melvynx/Parler

触发场景

需要创建组织作用域的公共API端点 实现API密钥相关的设置界面功能 为新的API端点生成文档

安装

npx skills add Melvynx/Parler --skill org-api-route -g -y
更多选项

非标准路径

npx skills add https://github.com/Melvynx/Parler/tree/main/web-app/.agents/skills/org-api-route -g -y

不安装直接使用

npx skills use Melvynx/Parler@org-api-route

指定 Agent (Claude Code)

npx skills add Melvynx/Parler --skill org-api-route -a claude-code -g -y

安装 repo 全部 skill

npx skills add Melvynx/Parler --all -g -y

预览 repo 内 skill

npx skills add Melvynx/Parler --list

SKILL.md

Frontmatter
{
    "name": "org-api-route",
    "description": "Create or update organization-scoped public `\/api\/v1\/*` routes backed by Better Auth API keys in NowStack. Use for API-key route work, org API actions\/queries, API-key settings UI, public API docs, and future endpoint patterns that must resolve an organization from an API key."
}

Org API Route

Build public API endpoints scoped to the organization that owns the API key. Keep route files tiny, keep auth and org resolution centralized, and document each endpoint as its own page.

Read First

Before editing, read:

  • convex/_generated/ai/guidelines.md
  • .agents/rules/api-routes.md
  • .agents/rules/convex-authorization-dto.md
  • .agents/rules/mdx.md when touching docs
  • Existing references:
    • src/lib/api/public-api.ts
    • convex/apiKeys/functions.ts
    • convex/apiKeys/actions.ts
    • convex/apiKeys/queries.ts
    • src/routes/api/v1/me.ts
    • src/routes/api/v1/members.ts
    • src/routes/api/v1/members.$memberId.ts
    • src/routes/orgs/$orgSlug/(navigation)/settings/api-keys/index.tsx
    • content/docs/api-me.mdx
    • content/docs/api-members.mdx
    • content/docs/api-member.mdx

Architecture

  • HTTP route files call only createPublicApiHandler(...).
  • Public Convex actions use orgApiAction(...).
  • Internal Convex reads use orgApiQuery(...).
  • verifyApiKeyForOrg(...) verifies the key and exposes organizationId.
  • Do not duplicate API-key extraction, verification, or org lookup in route files.
  • Do not call authClient from route files or the API-key settings UI.

Response Shape

  • Keep endpoint payloads focused on the resource requested.
  • Do not attach organization to every response by default.
  • Use GET /api/v1/me for the organization attached to the API key.
  • Use resource endpoints for resource payloads only:
    • GET /api/v1/members returns { members }.
    • GET /api/v1/members/:memberId returns { member }.
    • GET /api/v1/me returns { organization }.
  • createPublicApiHandler strips ok and status from successful action results before sending JSON.
  • Missing or invalid keys return 401.
  • Missing org or resource returns 404.

Documentation Rules

  • Always create one doc page per public endpoint.
  • Use .agents/skills/add-documentation/scripts/create-doc.sh for new docs, then replace the generated template with endpoint-specific content.
  • Title pages by operation, not broad groups:
    • List Organization Members API
    • Get Organization Member API
    • Current Organization API
  • Keep examples scoped to that endpoint only. Do not document list and detail endpoints on the same page.
  • Add every new or changed endpoint doc to CHANGELOG.md.

API-Key Settings UI

  • Creation happens in a dialog.
  • The newly generated key is revealed in a dialog only; never render a large inline one-time-key card under the page header.
  • Existing keys render in a table.
  • Row actions live in a dropdown menu, not inline icon buttons.
  • The docs entry near the API Keys title should stay minimal: a simple text link labeled Docs.

API Key CRUD Learning

@better-auth/api-key@1.6.10 can throw dynamic module import unsupported when its create/delete endpoint permission path runs inside a Convex mutation. For organization API-key settings:

  • Keep the outer function as orgMutation(...) with the repo's permission gate.
  • Create and delete keys through components.betterAuth.adapter.
  • Generate keys with the configured nsk_ prefix.
  • Store the SHA-256 base64url hash in the Better Auth apikey model.
  • Return the raw key only once from the create mutation.
  • Delete by both _id and referenceId so keys stay scoped to the active org.

Workflow

  1. Add or update the internal orgApiQuery.
  2. Add or update the public orgApiAction.
  3. Add or update the src/routes/api/v1/* route with createPublicApiHandler.
  4. Add or update exactly one docs page per endpoint.
  5. Update API-key settings UI only when the discoverability surface changes.
  6. Update CHANGELOG.md.
  7. Run pnpm ts, pnpm lint:ci, pnpm test:ci, and pnpm build when route behavior or docs are touched.

版本历史

  • 1aaa38b 当前 2026-08-20 07:35

同 Skill 集合

web-app/.agents/skills/add-documentation/SKILL.md
web-app/.agents/skills/apex/SKILL.md
web-app/.agents/skills/convex-cost-optimizer/SKILL.md
web-app/.agents/skills/convex-create-component/SKILL.md
web-app/.agents/skills/convex-migration-helper/SKILL.md
web-app/.agents/skills/convex-performance-audit/SKILL.md
web-app/.agents/skills/convex-quickstart/SKILL.md
web-app/.agents/skills/convex-setup-auth/SKILL.md
web-app/.agents/skills/convex/SKILL.md
web-app/.agents/skills/create-saas-idea/SKILL.md
web-app/.agents/skills/create-tests/SKILL.md
web-app/.agents/skills/dev-browser/SKILL.md
web-app/.agents/skills/init-project/SKILL.md
web-app/.agents/skills/intercepted-route-using-tanstack-start/SKILL.md
web-app/.agents/skills/optimizer/SKILL.md
web-app/.agents/skills/publish-to-production/SKILL.md
web-app/.agents/skills/setup-stripe/SKILL.md
web-app/.agents/skills/sync-with-nowstack/SKILL.md
web-app/.agents/skills/exa-search/SKILL.md
web-app/.agents/skills/find-docs/SKILL.md

元信息

文件数
0
版本
1aaa38b
Hash
acf9e4cc
收录时间
2026-08-20 07:35

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-09 21:09
浙ICP备14020137号-1 $访客地图$