Agent Skillsmastra-ai/mastra › configure-factory-rules

configure-factory-rules

GitHub

指导在部署代码中配置 Mastra Factory 的 typed 规则及精确叶覆盖。涵盖查找配置、保持公共结构、应用覆盖、版本管理及安全验证,确保策略代码的正确性与安全性。

mastracode/factory/factory-skills/configure-factory-rules/SKILL.md mastra-ai/mastra

Trigger Scenarios

修改工厂规则配置 添加或更新 Factory 规则测试

Install

npx skills add mastra-ai/mastra --skill configure-factory-rules -g -y
More Options

Non-standard path

npx skills add https://github.com/mastra-ai/mastra/tree/main/mastracode/factory/factory-skills/configure-factory-rules -g -y

Use without installing

npx skills use mastra-ai/mastra@configure-factory-rules

指定 Agent (Claude Code)

npx skills add mastra-ai/mastra --skill configure-factory-rules -a claude-code -g -y

安装 repo 全部 skill

npx skills add mastra-ai/mastra --all -g -y

预览 repo 内 skill

npx skills add mastra-ai/mastra --list

SKILL.md

Frontmatter
{
    "name": "configure-factory-rules",
    "description": "Configure typed Mastra Factory rules and exact-leaf overrides in deployment code"
}

Configure Factory Rules

Help the user change Factory policy in the typed deployment configuration. Factory rules are trusted server code. Never place deployment policy in this skill, repository instructions, browser code, or a parallel actions system.

Find the configuration

  1. Search for new MastraFactory, defaultFactoryRules, and the rules property.
  2. Read the existing rule configuration and its tests before editing.
  3. Import rule helpers and types from the same local Factory module used by the deployment.
  4. If the deployment doesn't configure rules, start with defaultFactoryRules({ version, overrides }) and pass the result to MastraFactory.

Do not guess a file path. Factory deployments can assemble MastraFactory from different entry points.

Preserve the public shape

Use one rules tree:

  • work.<stage>.<source>.onEnter or onExit
  • review.<stage>.<source>.onEnter or onExit
  • tools.<toolName>.onResult
  • github.<event>.onEvent

Do not create an actions config or execute authoritative policy in React. Each handler returns one typed FactoryRuleDecision or undefined.

Work and Review cards move independently. Never mirror their stages or mark Work Done only because a pull request merged.

Apply exact-leaf overrides

An override replaces the exact handler leaf. It does not compose with the built-in handler at that leaf. Sibling leaves remain unchanged.

Before replacing a built-in leaf:

  1. Read the built-in handler in src/web/factory/rules/defaults.ts.
  2. Decide whether the replacement must preserve part of that behavior explicitly.
  3. Use only fields exposed by the typed context. Do not reach into Factory storage or raw webhook payloads.
  4. Return undefined to allow the ingress with no decision, or return a typed rejection or bounded structured decision.
  5. Give every effect decision a stable idempotencyKey derived from immutable ingress identity.

Version changes

Set an explicit, deployment-owned version. Change it whenever rule behavior changes. The version identifies persisted evaluations and audit records; it must not be used as event identity or added to ingress deduplication keys.

Safety rules

  • Keep handler work within the five-second evaluation budget.
  • Treat rule callbacks as trusted deployment code, not repository-provided code.
  • Keep rejection reasons short and safe to persist and display.
  • Never expose credentials, storage handles, worktree paths, or raw webhook payloads to handlers.
  • Trust GitHub actors only after server-side permission resolution. Only write and admin are trusted; failures are untrusted.
  • Request follow-up transitions through FactoryRuleDecision. Never mutate stage storage directly.
  • Defer skill, message, notification, and linked-item effects. Never execute them inside evaluation.
  • Keep causal transitions bounded and include a stable idempotency key.

Verify the change

  1. Add or update focused tests for the replaced leaf and its unaffected siblings.
  2. Test undefined, accepted, and rejected paths when they apply.
  3. Run the narrow Factory rule tests and package typecheck.
  4. Run the Web build to confirm the skill and deployment output are packaged.
  5. Summarize the leaf replaced, behavior retained or removed, version change, and commands run.

Do not weaken tests or bypass the transition service to make a policy work.

Version History

  • fb538c4 Current 2026-08-20 17:27

Same Skill Collection

.agents/skills/label-core-bugs/SKILL.md
.claude/skills/debugging-difficult-bugs/SKILL.md
.claude/skills/docs-audit/SKILL.md
.claude/skills/e2e-tests-studio/SKILL.md
.claude/skills/label-core-bugs/SKILL.md
.claude/skills/mastra-docs/SKILL.md
.claude/skills/mastra-frontend/SKILL.md
.claude/skills/mastra-smoke-test/SKILL.md
.claude/skills/pr-explainer/SKILL.md
.claude/skills/pr-splitter/SKILL.md
.claude/skills/ralph-plan/SKILL.md
.claude/skills/react-best-practices/SKILL.md
.claude/skills/smoke-test/SKILL.md
.claude/skills/tailwind-v4/SKILL.md
.claude/skills/testing-core-processors/SKILL.md
.claude/skills/testing-mastracode-tui/SKILL.md
.mastracode/skills/gh-bulk-issues/SKILL.md
.mastracode/skills/herdr-kit-workflows/SKILL.md
.mastracode/skills/herdr-manager-query/SKILL.md
.mastracode/skills/label-core-bugs/SKILL.md
.mastracode/skills/understand-issue/SKILL.md
.mastracode/skills/understand-pr/SKILL.md
mastracode/factory/factory-skills/factory-complete-issue/SKILL.md
mastracode/factory/factory-skills/factory-plan/SKILL.md
mastracode/factory/factory-skills/factory-rereview/SKILL.md
mastracode/factory/factory-skills/factory-review/SKILL.md
mastracode/factory/factory-skills/factory-triage/SKILL.md
templates/template-claw-assistant/workspace/skills/general-tasks/SKILL.md
templates/template-claw-assistant/workspace/skills/research-tasks/SKILL.md
templates/template-github-review-agent/workspace/skills/code-standards/SKILL.md
templates/template-github-review-agent/workspace/skills/performance-review/SKILL.md
templates/template-github-review-agent/workspace/skills/security-review/SKILL.md
.claude/skills/builder-smoke-test/SKILL.md
.claude/skills/playground-msw-tests/SKILL.md
.mastracode/skills/triage-issue/SKILL.md

Metadata

Files
0
Version
fb538c4
Hash
6a0d6682
Indexed
2026-08-20 17:27

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 20:20
浙ICP备14020137号-1 $Carte des visiteurs$