用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/webiny/stdlib --skill adding-a-feature命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
How dependency injection works in @webiny/stdlib — abstractions, implementations, features, and container wiring.
Testing conventions for @webiny/stdlib — container setup, tmpdir patterns, browser environment directives.
Guided feature development for @webiny/stdlib using the DI abstraction → implementation → feature → index pattern. Use when adding a new tool, service, or feature to any slice (common, node, browser). Enforces TDD, file conventions, barrel exports, README creation, and the pre-commit chain. CRITICAL — existing tests must never be modified unless genuinely buggy.
基于 SOC 职业分类
正在显示 SKILL.md
| name | adding-a-feature |
| description | Step-by-step guide for adding a new tool or service to @webiny/stdlib. |
| context | guides |
This mirrors the "Step-by-step: Adding a New Tool to an Existing Package" section in the repo's AGENTS.md, which is the authoritative source — check there if this drifts.
First decide which slice the tool belongs in, based on its runtime dependencies:
| Uses only JS built-ins / standard lib | → @webiny/stdlib root (src/) |
| Uses node:* APIs or Node-only npm packages | → @webiny/stdlib/node (src/node/) |
| Uses window, document, React, browser APIs | → @webiny/stdlib/browser (src/browser/) |
src/node/ and src/browser/ must NOT import from each other. Both may import common code via ~/common/index.js.
Example below: adding HttpTool to @webiny/stdlib/node. Substitute the appropriate slice and path for your tool.
Create the abstraction at src/node/features/HttpTool/abstractions/HttpTool.ts:
interface IHttpTool with JSDoc on each method.const HttpTool = createAbstraction<IHttpTool>("Core/HttpTool").namespace HttpTool { export type Interface = IHttpTool }.Create the abstraction barrel at src/node/features/HttpTool/abstractions/index.ts:
export { HttpTool } from "./HttpTool.js";Create the implementation at src/node/features/HttpTool/HttpTool.ts:
import { HttpTool as HttpToolAbstraction } from "./abstractions/HttpTool.js";import { Logger } from "~/common/index.js";class HttpToolImpl implements HttpToolAbstraction.Interface { ... }export const HttpTool = HttpToolAbstraction.createImplementation({ implementation: HttpToolImpl, dependencies: [...] })dependencies array order must match the constructor parameter order exactly.Create the feature at src/node/features/HttpTool/feature.ts:
export const HttpToolFeature = createFeature({ name: "Core/HttpToolFeature", register(container) { container.register(HttpTool).inSingletonScope(); } })Create the feature index at src/node/features/HttpTool/index.ts:
export { HttpTool } from "./abstractions/index.js";export { HttpToolFeature } from "./feature.js";createImplementation output.Create the feature README at src/node/features/HttpTool/README.md:
createXxx() factory function.name, description, context) so the README is discoverable by the MCP server — see the front-matter block at the top of any existing feature README for the exact shape.README.md table to add a row pointing to the new feature README.Add to the slice barrel src/node/index.ts:
export { HttpTool, HttpToolFeature } from "./features/HttpTool/index.js";Write tests at __tests__/node/HttpTool.test.ts:
makeContainer() helper — see the testing-patterns skill.// @vitest-environment directive (only browser tests do).Run the pre-commit chain until fully clean:
yarn && yarn adio && yarn format:fix && yarn lint:fix && yarn typecheck && yarn build && yarn test:coverage
All steps must pass with zero errors and zero warnings before staging and committing. If any step fails, fix the issue and run the full chain again from the start.
tsconfig.json must pass..js extensions in package source imports — under src/, import { Foo } from "./Foo.js" (not .ts); tsgo resolves .js to .ts at compile time. (Exception: scripts/, which runs directly under Node 24 and needs real .ts extensions.)node: prefix for Node built-ins — import { readFileSync } from "node:fs", never "fs"..inSingletonScope() unless there's a reason not to."Domain/ToolName" format — "Core/" prefix for common utils, "Node/" prefix for Node-specific ones.namespace ToolName { export type Interface = IToolName } alongside the token.See the di-patterns skill for the underlying abstraction/implementation/feature mechanics, and AGENTS.md's "Step-by-step: Adding a New Slice to @webiny/stdlib" section if you're adding an entirely new runtime environment rather than a tool within an existing one.