Token导航 LogoToken导航

Agent Skill · 研究检索

cdk-rest-api-postgres(CDK rest API Postgres 搜索)

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

cdk-rest-api-postgres 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 65,612。

总安装 279周安装 12GitHub Stars 1下载 98核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cdk-rest-api-postgres(CDK rest API Postgres 搜索)
来源仓库:https://github.com/stack-shifter/skills
仓库路径:skills/cdk-rest-api-postgres
安装命令:
npx skills add https://github.com/stack-shifter/skills --skill cdk-rest-api-postgres
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/stack-shifter/skills --skill cdk-rest-api-postgres

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

cdk-rest-api-postgres 用于辅助设计基于 Postgres 的 REST API,提供接口结构、路由模式和数据库集成指导。适合在 Codex、Claude、Cursor、Gemini CLI 中设计 API 端点、生成 OpenAPI 草稿或检查字段命名规范时调用。

使用时需确认业务语义、鉴权方式、分页规则和错误处理逻辑,避免凭空补字段。建议从现有代码、schema 或接口样例中提取事实作为设计依据。该技能以 Drizzle ORM 为默认持久化模型,支持 AWS CDK 环境部署。

来源仓库内路径:skills/cdk-rest-api-postgres

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/stack-shifter/skills --skill cdk-rest-api-post…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

cdk-rest-api-postgres 怎么安装?

在终端执行 npx skills add https://github.com/stack-shifter/skills --skill cdk-rest-api-postgres。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

cdk-rest-api-postgres 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

cdk-rest-api-postgres 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

cdk-rest-api-postgres 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

cdk-rest-api-postgres 用的人多吗?

公开数据是累计安装 279 次,近一周安装 12 次,下载 98 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

cdk-rest-api-postgres 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
cdk-rest-api-postgres

CDK rest API Postgres 搜索 · 本页

2791接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Purpose

Use this skill to design and implement Postgres-backed REST APIs on AWS in a way that fits the target repository.

Treat Postgres plus Drizzle as the default persistence model. When the repository already has compatible constructs and runtime patterns, extend them. When those pieces do not exist, use the references in this skill as portable patterns to generate an equivalent structure.

Portable references live in references/. Load only the patterns needed for the task:

  • references/rest-api-pattern.md for centralized REST route composition patterns
  • references/node-lambda-pattern.md for Lambda defaults and environment wiring
  • references/importer-pattern.md for importing existing AWS resources into the stack
  • references/response-pattern.md for controller and middleware response conventions
  • references/sql-drizzle-pattern.md for Drizzle schema, repository, and DatabaseContext guidance
  • references/auth-pattern.md for Cognito authorizer, scopes, and handler-level group authorization
  • references/runtime-composition-pattern.md for src/app.ts singleton wiring and dependency aggregation
  • references/middleware-pattern.md for reusable Middy middleware such as auth, validation, HTTP error handling, and Powertools logger injection
  • references/services-pattern.md for logger, storage, notification, and mapper service design
  • references/utilities-pattern.md for RestResult, error types, status codes, cursor helpers, and related utilities
  • references/schedule-pattern.md for EventBridge-triggered scheduled Lambda jobs

Repository Rule

This skill is repository-aware, not file-path-bound.

The source of truth order is:

  1. The target repository's current architecture, naming, and abstractions
  2. The patterns in this skill's references
  3. The inline examples in this skill

If the local code differs from examples in this skill, follow local code and use the examples only as design guidance.

Repository Discovery

Start every use of this skill with a short discovery pass before proposing code.

Inspect only the parts of the repository that matter for the request. Common places include:

  • lib/core-stack.ts
  • lib/constructs/rest-api.ts
  • lib/constructs/node-lambda.ts
  • lib/constructs/api-models.ts
  • src/handlers/
  • src/controllers/
  • src/middlewares/
  • src/services/
  • src/models/validation/
  • src/data/db/
  • src/data/repositories/
  • src/data/context.ts
  • src/utilities/rest-result.ts
  • src/utilities/
  • src/app.ts

Look for:

  • how the route is registered in CDK
  • which handler export name the stack expects
  • which Middy middleware chain the handler follows
  • whether the controller already exists or should be added
  • whether a repository or schema already models the data
  • whether shared services or mappers already exist for the resource area
  • whether middleware or utilities already solve validation, authorization, cursor parsing, or error handling
  • whether the change needs environment variables from getDefaultLambdaEnvironment
  • whether handler files export a typed HANDLER registry constant to use for handlerName wiring
  • whether src/data/db/schema/ modules already define the relevant table, and whether a schema index re-exports them
  • whether a migration workflow exists (drizzle.config.ts, a drizzle/ folder) and what command generates migrations — confirm before proposing schema changes
  • whether src/data/db/client.ts already exports a shared db client and Db type
  • whether src/middlewares/inject-lambda-context.middleware.ts exists — adapter that bridges @aws-lambda-powertools/logger/middleware with Middy v7; used inside withCommonMiddleware in every handler file

After discovery, choose the appropriate approach and state it:

  • Existing pattern mode: the repository already has abstractions worth extending
  • Pattern generation mode: the repository is missing one or more pieces, so generate code that establishes the pattern cleanly

Existing Pattern Mode

Use the repository's existing abstractions directly:

  • RestServerlessApi for API Gateway REST route composition
  • NodeLambda for Lambda defaults and bundling
  • Importer when the stack needs to attach to existing AWS resources
  • RestResult for API Gateway response objects
  • DatabaseContext plus Drizzle repositories for persistence
  • src/middlewares/inject-lambda-context.middleware.ts for AWS Powertools logger injection in handler pipelines

Avoid hand-rolling raw API Gateway, Lambda, or persistence wiring unless the existing abstractions clearly cannot support the requirement.

Pattern Generation Mode

Use this mode when the target repository has no reusable abstraction for one or more layers.

In this mode:

  • use the references as guidance for the shape of the code, not as a demand that exact filenames or classes exist
  • create only the minimal new abstraction needed to keep the generated code coherent and reusable
  • prefer introducing a small reusable construct, helper, middleware, service, or repository pattern over shipping one-off route code
  • keep the generated names and folders aligned with the target repository's conventions, even when the conceptual pattern comes from this skill

Working Rules

  1. Read the relevant local construct, stack, handler, controller, and repository code before editing.
  2. If the repository already has a route composition abstraction such as RestServerlessApi, use it. If not, generate a small reusable pattern instead of scattering raw CDK logic.
  3. Keep handlers thin. Put orchestration in controllers and persistence in src/data/repositories/.
  4. For database work, model schema in Drizzle and query via a shared db client or equivalent shared database access layer.
  5. Reuse an existing dependency composition pattern such as DatabaseContext or src/app.ts when it exists. If it does not, create a lightweight equivalent rather than wiring dependencies ad hoc in handlers.
  6. Reuse the local Middy middleware stack pattern when it exists. If it does not, generate a reusable middleware composition pattern instead of inlining validation and auth in every handler.
  7. Return responses through the local response helper when one exists. Otherwise generate one shared response utility instead of repeating inline response objects.
  8. Preserve Cognito authorizer behavior and group-based authorization middleware when extending protected routes.
  9. Prefer service classes and mapper classes for cross-cutting logic that appears in more than one controller.
  10. Centralize reusable error and cursor helpers under src/utilities/ or an equivalent shared module rather than duplicating them in repositories or handlers.
  11. Prefer small reusable services for cross-cutting concerns such as logging, storage, notifications, and DTO mapping. When the same concern appears in more than one controller, extract it into a shared service rather than duplicating it inline.

Default Assumptions

  • API type: API Gateway REST API
  • Compute: one Lambda handler export per route
  • Datastore: Postgres via Drizzle and the shared Neon HTTP client
  • Runtime defaults: existing Lambda wrapper defaults when present, otherwise a consistent Node.js Lambda baseline
  • Auth: Cognito authorizer at API Gateway plus authorizedGroup(...) in handlers when needed
  • Validation: Zod schemas through validation.middleware.ts
  • Environment: Lambda runtime should receive shared database and app settings through one central helper or wiring layer when possible

If the user gives constraints that conflict with these defaults, adapt and state the change.

Project Shape

Use a structure like this when the repository does not already provide a better one:

lib/
├── constructs/
└── core-stack.ts

src/
├── controllers/
├── data/
│   ├── db/
│   │   ├── client.ts
│   │   └── schema/
│   ├── context.ts
│   └── repositories/
├── handlers/
├── middlewares/
├── models/
│   └── validation/
├── services/
├── utilities/
└── app.ts

Treat this as a conceptual layout, not a hard requirement:

  • lib/core-stack.ts or an equivalent stack module registers routes and shared route defaults
  • src/handlers/ contains Middy-wrapped Lambda exports
  • src/controllers/ contains request orchestration and response shaping
  • src/data/db/schema/ defines Drizzle Postgres tables and relations
  • src/data/repositories/ contains SQL access logic
  • src/data/context.ts or an equivalent module wires repositories to a shared Db and exposes a shared runtime context
  • src/services/ holds logger, storage, notification, mapper, and other integration-facing services
  • src/utilities/ holds response helpers, error types, status codes, cursor helpers, and shared pure functions
  • src/models/validation/ contains Zod schemas for request validation

Construct-Centered Guidance

1. Route composition should be centralized

If the repository already has a route composition abstraction such as RestServerlessApi, extend it. Otherwise create one reusable route composition layer and keep route registration centralized.

Common route helpers are:

  • get
  • getById
  • post
  • put
  • delete

Set shared defaults once:

const cognitoAuthorizer = api.createCognitoAuthorizer(userPool);

api.setDefaultRouteOptions({
    authorizer: cognitoAuthorizer,
    environmentVariables: getDefaultLambdaEnvironment(),
});

Important pattern details:

  • routePath must start with /
  • default route options merge with per-route options
  • setting authorizer: undefined on a route removes the default authorizer
  • scopes are typically passed per route in the stack layer
  • route grants are connection-based; no table-level IAM grants are needed for SQL persistence

2. Lambda runtime defaults should be centralized

If the repository already has a Lambda wrapper such as NodeLambda, use it. Otherwise generate a small shared wrapper or helper that centralizes runtime defaults.

Useful baseline defaults include:

  • Node.js 24.x
  • ARM64
  • 128 MB memory unless overridden
  • 15 second timeout unless overridden
  • active X-Ray tracing
  • CloudWatch log group with three-month retention
  • bundling with @aws-sdk/* externalized

A shared environment helper often needs values such as:

  • DATABASE_URL
  • FRONTEND_URL
  • S3_BUCKET
  • SES_IDENTITY_EMAIL
  • SES_IDENTITY_EMAIL_ARN
  • optional CORS_ORIGIN
  • optional ALLOWED_GROUP

When adding routes, inherit shared environment wiring unless there is a strong reason not to.

Three helpers are commonly used together in the stack: getDefaultLambdaEnvironment(), getStackLambdaName(), and createSendEmailPolicy(). See references/node-lambda-pattern.md for their signatures, usage, and the pattern for attaching the SES policy.

3. Keep route wiring readable and repetitive in the right way

Never write handlerName as a bare string literal — a rename in the handler file will not be caught at compile time without a registry. Each handler file should export a typed HANDLER registry constant, which the stack imports and uses for all route wiring.

Prefer:

  • one handler file per resource area
  • HANDLER registry constants exported from each handler file and imported by the stack
  • lambdaName() and handlerPath() local helpers wrapping getStackLambdaName and path.join
  • shared Cognito authorizer defaults with per-route scopes

See references/rest-api-pattern.md for the full registry template, multi-route stack examples, and the setDefaultRouteOptions setup.

4. Prefer Importer for existing infrastructure

If the repository exposes an importer helper like lib/constructs/api-importer.ts, use it when wiring a stack to resources that already exist.

Prefer patterns like:

import { Importer } from './constructs/api-importer';

const userPool = Importer.getCognitoUserPoolById(this, process.env.COGNITO_USER_POOL_ID!);
const s3Bucket = Importer.getS3Bucket(this, process.env.S3_BUCKET!);
const apiDomain = Importer.getApiGatewayDomainName(
    this,
    process.env.API_DOMAIN_NAME!,
    process.env.API_DOMAIN_NAME_ALIAS!,
    process.env.ZONE_ID!,
);

Use the importer when the stack attaches to an existing user pool, S3 bucket, domain, or other shared resource, and the repository already centralizes from* imports behind an importer helper. Do not replace a repository-wide importer with direct fromUserPoolId or similar calls unless the user explicitly asks for it.

See references/importer-pattern.md for the portable shape.

5. Prefer RestResult for API responses

If the repository has a response helper like src/utilities/rest-result.ts, use it as the default response format for controllers.

Prefer methods such as:

  • RestResult.Ok(...)
  • RestResult.Created(..., location)
  • RestResult.NoContent()
  • RestResult.BadRequest(...)
  • RestResult.Unauthorized(...)
  • RestResult.Forbidden(...)
  • RestResult.NotFound(...)
  • RestResult.Conflict(...)
  • RestResult.InternalServerError(...)

Use RestResult.fromDatabaseError(error) before falling through to a generic 500 whenever a repository operation could fail with a recognized Postgres constraint error. This keeps CORS headers, content types, status codes, and error body shapes consistent across all endpoints.

If no local response helper exists, load references/response-pattern.md for the full class shape and baseline implementation.

6. Use ScheduleLambda for EventBridge-triggered background jobs

If the repository exposes a scheduled Lambda construct (e.g., lib/constructs/schedule.ts), use it for any non-API background work such as soft-delete cleanup, digest emails, or data expiry sweeps. Do not create a raw events.Rule + NodejsFunction pair inline.

Key points:

  • the scheduled Lambda follows the same HANDLER registry pattern as API handlers
  • the handler entrypoint type is ScheduledEvent from aws-lambda, not APIGatewayProxyEvent
  • for Postgres-backed jobs, pass DATABASE_URL through getDefaultLambdaEnvironment() — no table-level IAM grants are needed

See references/schedule-pattern.md for the full construct snippet, handler template, and all key options.

Runtime Guidance

Handlers

Handlers should follow the local Middy pattern:

  • httpHeaderNormalizer()
  • httpEventNormalizer()
  • handleHttpError()
  • httpJsonBodyParser({disableContentTypeError: true}) for write routes
  • authorizedGroup(...) when group authorization is required
  • validateHeaders(...), validatePathParameters(...), validateQueryParameters(...), and validateBody(...) as needed

Keep handler files mostly declarative. They should compose middleware around controller functions rather than implement business logic directly.

If the repository does not yet have a consistent handler pattern, generate one that keeps:

  • middleware composition in the handler
  • orchestration in the controller
  • persistence in repositories
  • shared concerns in middleware, services, and utilities

Controllers

Controllers should:

  • read typed event data after middleware validation
  • call dbContext and other shared services from a shared composition module
  • map entities through the repository and mapper layers
  • return RestResult responses
  • translate repository failures with RestResult.fromDatabaseError(...) when applicable

Data Layer

Persistence work belongs under src/data/ or an equivalent data layer.

Preferred flow:

  1. define or update table schema in src/data/db/schema/
  2. export it through the schema index if needed
  3. implement repository behavior in src/data/repositories/
  4. wire the repository through src/data/context.ts if it is a new repository
  5. consume it from controllers via dbContext

Do not open raw database connections inside handlers or controllers. Reuse the shared db and DatabaseContext or an equivalent context pattern.

Drizzle Schema Rules

When adding or changing persistence:

  • use pgTable, typed columns, indexes, enums, and relations from Drizzle
  • keep relations centralized in a dedicated schema module when appropriate
  • mirror existing schema naming and table file conventions when they already exist
  • prefer SQL constraints and indexes over application-only uniqueness logic
  • generate migrations with the repo's Drizzle workflow, or introduce one coherent migration workflow instead of inventing manual SQL files

Repository Rules

Repository APIs in this skill should stay SQL-oriented, not key-value oriented.

Prefer methods that reflect domain behavior, for example:

  • getById
  • query
  • save
  • updateById
  • delete
  • relation-specific helpers when needed

For cursor pagination, do not assume UUID v4 primary keys are time-ordered. Prefer a stable ordered tuple such as created_at plus id, and make the cursor carry both values.

When generating a repository pattern from scratch:

  • define repository methods around domain actions rather than query-builder details
  • keep transaction boundaries above the repository only when multiple repositories must coordinate
  • keep mapping from raw row shape to API response out of the handler
  • avoid importing Drizzle schema objects directly into handlers unless the repository layer does not exist yet

Response and Error Rules

Use src/utilities/rest-result.ts or an equivalent shared response helper for all API responses.

Prefer:

  • RestResult.Ok(...)
  • RestResult.Created(...)
  • RestResult.NoContent()
  • RestResult.BadRequest(...)
  • RestResult.NotFound(...)
  • RestResult.Unauthorized(...)
  • RestResult.Forbidden(...)
  • RestResult.InternalServerError(...)

For recognized Postgres constraint failures, prefer RestResult.fromDatabaseError(error) before falling back to generic 500 handling.

Auth Rules

Protected routes should usually use two layers:

  1. API Gateway Cognito authorizer and scopes in CDK
  2. handler-level group authorization via authorizedGroup(...)

When changing protected routes:

  • preserve route scopes in the stack layer
  • preserve or extend group checks in handlers
  • use existing ALLOWED_GROUP semantics when present
  • do not reintroduce removed client-account auth flows

Change Patterns

When adding a new CRUD endpoint, the usual path is:

  1. add or update the Drizzle schema if persistence changes
  2. add or extend the repository
  3. add or extend the controller
  4. add or extend the handler with Middy middleware and validation
  5. register the route in the stack or route-composition layer
  6. add focused tests for the changed behavior

When the request is only infrastructure-facing, still confirm whether handler, controller, repository, validation, or environment wiring also needs to move with it.

When generating the architecture from scratch, prefer this order:

  1. define or update the data model and migration
  2. define repository methods around the use case
  3. define controller behavior and response mapping
  4. add handler middleware and validation
  5. register the route and shared environment wiring
  6. add tests around the repository, controller, or handler boundary that changed

Response Style

When using this skill, produce:

  1. A short statement of the endpoint(s) being added or changed
  2. A note saying whether you are using Existing pattern mode or Pattern generation mode
  3. CDK snippets based on local constructs when present, or the portable baseline when not
  4. The data layer change: new Drizzle schema and migration needed, or existing schema extended
  5. Any handler, controller, repository, or validation follow-on work needed to make the endpoint functional
  6. Explicit assumptions where auth, schema, or validation is ambiguous

Avoid generic AWS guidance when a repository-specific construct snippet would answer the request better. Treat the repository's code as authoritative and the skill as workflow guidance, not as a competing source of truth.

Definition of Done

A change using this skill is usually complete when:

  • the route is registered through the local CDK abstractions
  • the handler matches the repository's Middy style or establishes one coherent style
  • controller and repository responsibilities stay separated
  • persistence uses Drizzle and Postgres only
  • tests cover the changed behavior at the right layer

平台分布

Codex

36.12%
按下载量换算35

Claude

32.07%
按下载量换算31

Cursor

19.86%
按下载量换算19

Gemini CLI

9.72%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills