Chuyển đến nội dung
Skillpedia
Bảo mật7.6k · #13179

secrets

Skill này làm gì

Skill này giải thích cách ứng dụng nên lưu và dùng thông tin xác thực như khóa API và kết nối OAuth. Skill dành cho lập trình viên thêm tính năng cần đăng nhập hoặc khóa của người dùng hay workspace.

Khi nào nên dùng

  • ✓Khi một tính năng cần khóa API hoặc đăng nhập dịch vụ bên ngoài.
  • ✓Khi bạn thêm OAuth để người dùng kết nối một tài khoản.
  • ✓Khi bạn muốn dán một khóa vào code nguồn hoặc một giá trị cài đặt thường.

Liên kết skill

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/secrets/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/secrets/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thêm một tính năng cần khóa API, và đảm bảo khóa được lưu an toàn chứ không nằm trong code.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent trước hết kiểm tra kết nối hiện có, rồi dùng luồng OAuth chung hoặc hệ thống bí mật chung. Khóa không bao giờ được đặt trong code ứng dụng hoặc trạng thái hiển thị với client.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Secrets

Rule

Credentials belong to the user, organization, workspace, or deployment that owns them. Reuse the strongest shared connection or credential flow available; never copy a value into app code or client-visible state.

Choose the credential source

  1. Check the workspace connection catalog first. If the provider is already connected, request the app grant and resolve its vault-backed credential reference through the workspace-connection API.
  2. For OAuth, use the shared authorization and token flow. Do not store access or refresh tokens as ordinary settings or API-key values.
  3. If the app truly needs its own API key, register it with the shared secrets surface. Do not build a parallel key form or storage table.
  4. Use deployment configuration only for a secret owned by the deployed app, such as a webhook verification secret. LLM inference keys are an app-owned exception: self-hosted apps may use provider keys from deployment env as a shared fallback, while scoped user or organization keys take precedence. Hosted-workspace deployments backed by a shared database must not share those env keys across apps or tenants. This exception does not authorize using env credentials to access user-owned provider data.

Register an app-local API key

Register the key once so Settings can manage it and the app can describe why it is needed. Supported scopes are user, org, and workspace; choose the narrowest scope that matches who owns the credential and how the app resolves it. Put the registration in a server module imported by a loaded server plugin.

import { registerRequiredSecret } from "@agent-native/core/secrets";

registerRequiredSecret({
  key: "EXAMPLE_SERVICE_API_KEY",
  label: "Example service API key",
  description: "Connects this app to the example service.",
  docsUrl: "https://example.com/api-keys",
  scope: "user",
  kind: "api-key",
  required: true,
});

Use kind: "oauth" for an OAuth-backed connection and set oauthProvider and oauthConnectUrl for the shared Connect flow. Set required only when the app cannot perform its primary workflow without that connection. A validator may check a key before save; never log or include the value in a validation error.

Resolve credentials on the server

Resolve credentials only inside server-side actions or server helpers, using the request's user and organization context. Keep a missing key separate from a failed credential-store lookup: ask the user to connect the provider only when the credential is absent; make a store failure retryable.

For an app-local key, use resolveSecretDetailed() from @agent-native/core/server in the request context. Check lookupFailed before checking value; do not turn a failed lookup into a setup prompt.

Never read a user's or workspace's API key from process.env, or add a raw environment fallback to a scoped lookup. Do not put credentials in action arguments or results, agent messages or hidden context, application state, browser storage, client bundles, logs, or error text. Send them only in the provider request that needs them, and redact provider responses before returning an error.

Related skills

  • security — protect access to app data and external requests.
  • actions — expose server-side operations to both the agent and UI.
Câu hỏi thường gặp

Khóa có thể lưu như cài đặt thông thường không?

Không. Token truy cập và token làm mới không được lưu như cài đặt thường hay giá trị khóa API.

Khi nào được dùng biến môi trường?

Chỉ cho các giá trị ở cấp triển khai, chẳng hạn bí mật xác minh webhook.

Nếu nhà cung cấp đã được kết nối thì sao?

Ứng dụng dùng kết nối hiện có thay vì yêu cầu người dùng nhập khóa lần nữa.

Chi tiết

Mô tả gốc của tác giả

Connect external services and keep app credentials scoped. Use before adding an API key, OAuth connection, provider setup, or server-side request that needs a user's or workspace's credential.

repo: BuilderIO/agent-native

Độ phổ biến

Sao GitHub
7.6k
Vị trí xếp hạng
#13179
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự