一键导入
safe-change
Structured safe-change workflow for documented codebases. Reads and writes only canonical YAML artifacts under a resolved structured docs root.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Structured safe-change workflow for documented codebases. Reads and writes only canonical YAML artifacts under a resolved structured docs root.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Structured reconstruction workflow for unfamiliar or undocumented codebases. Produces agent-first YAML artifacts only under a resolved structured docs root, with no prose Markdown fallback.
Structured greenfield project workflow. Creates agent-first YAML project truth under a resolved structured docs root plus root AGENTS.md for harness interoperability.
Validate canonical structured YAML artifacts for schema shape, reference integrity, evidence quality, coverage, and granularity. Read-only by default; no legacy prose docs.
Migration workflow from deprecated prose-style docs/agent Markdown artifacts to canonical structured YAML artifacts under a resolved structured docs root. No fallback or Markdown generation.
Architecture-aware review against canonical structured YAML artifacts. Read-only workflow; no legacy prose docs.
| name | safe-change |
| description | Structured safe-change workflow for documented codebases. Reads and writes only canonical YAML artifacts under a resolved structured docs root. |
Goal: make changes without architecture drift using canonical structured artifacts.
Legacy prose artifacts are deprecated. Do not create, update, or rely on docs/agent/*.md, scoped prose docs, or generated human-readable Markdown views. Use structured YAML for canonical artifacts. Root AGENTS.md remains a harness interoperability file and may be generated/updated only by workflows that explicitly say so.
Resolved structured docs root:
Treat docs/agent/api as a logical layout rooted at a resolved structured docs root, not a fixed repo path.
Resolution rules:
workspace_root with git rev-parse --show-toplevel 2>/dev/null or fallback to pwd.workspace_root before fingerprinting when possible (realpath, pwd -P, Path(...).resolve(), or equivalent).safe-start always creates and uses the initial repo-local root: <workspace_root>/docs/agent/api.safe-change uses repo-local only when <workspace_root>/docs/agent/api already exists.~/.pi/agent/workspaces/<workspace-fingerprint>/docs/agent/api.<workspace-fingerprint> exactly from canonical workspace_root: strip one leading slash/backslash, replace every slash, backslash, and colon with -, then wrap with --. This keeps the same workspace stable./data/data/com.termux/files/home/CodeProjects/pi-mono -> --data-data-com.termux-files-home-CodeProjects-pi-mono--.Logical structured layout under the resolved docs root:
repo/
scopes.yaml
repo-inventory.yaml
project-intent.yaml
architecture.yaml
data-flow.yaml
data-model.yaml
invariants.yaml
dependency-rules.yaml
design-issues.yaml
risk-register.yaml
change-guide.yaml
testing-strategy.yaml
validation-baseline.yaml
contracts.yaml
adr.yaml
agent-operating-guide.yaml
scopes/
by-path/<repo-relative-path>/...
by-domain/<slug>/...
Every structured artifact must conform to ../_shared/references/schemas/common.schema.json plus its artifact-specific schema. Do not inline, invent, or vary envelope fields.
Stable IDs required: scope:*, component:*, entity:*, invariant:*, risk:*, contract:*, flow:*, command:*, issue:*, adr:*, testplan:*.
Ownership rules:
scopes: scope routing, ownership, cross-scope discovery only.repo-inventory: file tree, commands index, entry points, external boundaries, configs.validation-baseline: command status, blockers, recommended validation order.project-intent: product goal, users, journeys, must-have features, non-goals, constraints, assumptions, open questions, success metrics, prioritized quality attributes, operating constraints, risk areas.architecture: components, architecture style, style rationale, alternatives/tradeoffs, side-effect boundaries, deployment/operating shape, reliability expectations, observability expectations, security assumptions, high-level flow refs.data-flow: typed flow graph/steps, trust boundaries, sensitive-data handling steps, inputs, outputs, error states, degradation/recovery notes.data-model: entities, IDs, schemas, relationships, lifecycles, serialized formats, retention/compliance notes.invariants: rules, forbidden states, enforcement locations, invariant-test refs.dependency-rules: layers, allowed/forbidden dependencies, violations, coupling hotspots.design-issues: structural drift, deferred decisions, ambiguity, ownership gaps.risk-register: failure modes, severity/confidence, affected refs, mitigations/recommended actions, suggested tests/fixes.contracts: cross-scope APIs, schemas, events, generated clients, DB/file/deployment/env/auth/telemetry contracts.testing-strategy: test topology, quality-attribute coverage, coverage gaps, risk-to-test priorities, operability checks.change-guide: workflow routing and checklists; references owner artifacts, duplicates no facts.adr: structured decision records with bounded prose fields, including alternatives and consequences for major design choices.agent-operating-guide: structured source for agent operating rules. Root AGENTS.md may mirror this in compact harness-readable Markdown when produced by safe-start or codebase-recon Pass 6.Redundancy rule: define each fact in its owner artifact exactly once. Other artifacts reference IDs.
Current truth rule: canonical YAML artifacts represent current state, not audit history. Remove resolved or superseded records from canonical owner artifacts by default. Keep them only when another live record still references them or an active migration requires temporary continuity. Use Git history, PRs, issues, or ADRs for audit/history.
Prose rule: bounded prose allowed only in summary, notes, rationale, context, decision, recommended_action, and similar scalar fields.
Scope rule: if focus is path-like, write under <docs-root>/scopes/by-path/<focus>/; otherwise under <docs-root>/scopes/by-domain/<slug>/. Always update <docs-root>/repo/scopes.yaml.
When a workflow creates, updates, migrates, or validates structured artifacts, read ../_shared/references/artifact-api.md first. Then read only the shared skill package schemas needed for the artifacts being written:
../_shared/references/schemas/common.schema.json../_shared/references/schemas/<artifact-file-base>.schema.jsonDo not read all schemas. Do not use templates. Schemas are runtime API contracts; project docs outside the shared runtime refs are maintainer aids unless the user asks about this package itself.
Use this protocol whenever creating or updating YAML artifacts.
<docs-root>/repo/scopes.yaml when present.risk:<slug>, entity:<slug>, component:<slug>, etc.artifact_id values use repo:<artifact-slug> for repo-level artifacts and <scope.id>/<artifact-slug> for scoped artifacts, e.g. repo:architecture and scope:packages/ai/architecture.scope:packages/ai:architecture is invalid.For each discovered fact/object:
order field.status: stale or deprecated only when a live reference still depends on it or an active migration needs temporary continuity. Add evidence/unknown explaining why, and link replacement ID when known.evidence_mode: planned and confidence low or medium.unknowns.status: current or confidence high without source or command evidence.Before writing final artifacts:
*_ref, *_refs, and depends_on ID points to a record in the same artifact set or is explicitly listed as external/unknown.scopes.yaml and contracts.yaml identify owner/consumer relationship.design-issues.yaml with kind: ownership_gap and reference it.Allowed transitions:
planned -> partial -> currentcurrent -> stale -> currentcurrent|stale|partial -> deprecatedRules:
current requires sufficient observed evidence for the represented scope.partial means useful but incomplete evidence.stale means contradicted by newer source evidence or missing source path. Use it as a temporary migration/quarantine state, not a permanent archive state.deprecated means superseded; include replacement_ref when known. Use it only when a live reference still needs continuity during migration; otherwise remove the record from the canonical artifact.id; keep ordered flow/checklist arrays by order.null, [], or {} consistently rather than omitting required envelope fields.Perform best-effort validation after writing:
AGENTS.md when explicitly produced for harness interoperability.Read these modular references at the matching workflow step:
references/preflight.md.<docs-root>/repo/scopes.yaml exists or task has a path/domain focus, also read references/scoped-docs.md.references/bug-fix.md before diagnosis/implementation.references/feature.md before design/implementation.references/refactoring.md before design/implementation.references/risk-fix.md before selecting/fixing a risk.references/preflight.md; read references/docs-update.md only if durable testing/risk facts change.references/docs-update.md before writing YAML artifacts.References inherit this skill's Structured Artifact API Contract and Write/Update Protocol. If a reference conflicts with this skill, this skill wins.
Before edits, produce:
repo/scopes.yamlUsers may invoke this skill directly for any workflow, or use the matching prompt template as a shortcut.
/preflight): classify task, match scope, identify owner artifacts/refs, and decide proceed vs approval./bug-diagnose): diagnose expected behavior, violated invariant/contract/risk, impacted quality attributes or operating constraints, root cause, minimal fix, regression test./bug-implement): implement approved minimal fix, add regression test, validate, update durable YAML facts only when semantics changed./feature-design): design flow/data/invariant/contract/component impacts, side effects, quality/security/reliability implications, tests, docs updates./feature-implement): implement approved design minimally, test, validate, update owner YAML artifacts when durable semantics changed./refactor-design): preserve behavior and documented quality expectations, identify design issue/dependency rule, characterization tests, staged plan./refactor-implement): execute approved refactor stage, keep behavior stable, validate./risk-fix): select one risk or failing risk-derived test, fix minimally, update risk status and related verification refs.Update owners only:
project-intent.yamlrepo-inventory.yamlvalidation-baseline.yamlarchitecture.yamldata-flow.yamldata-model.yamlinvariants.yamldependency-rules.yamlcontracts.yamlrisk-register.yamldesign-issues.yamltesting-strategy.yamlchange-guide.yaml