name: f2s-kb-migrate
description: Migrate a legacy knowledge base to .Knowledge in one pass: use the configuration-root docs-index.md plus the unified rule entry (legacy rules/main.md(c) or current package rules/f2s-flow2spec-unified-entry.md(c)) as primary index clues; fully process business rules/ and business skills/ (excluding f2s-* package skills), and fully migrate stock-docs/req-docs; after migration acceptance, must write .Knowledge/migration-report.md (migration mapping table + proposed deletion path list); closing must delete migrated legacy rules/, migrated business skills/, and legacy docs-index.md/index-doc.md; the user only reviews/revises the deletion list (exclusions); triggers: f2s-kb-migrate、知识库迁移、旧版迁移、knowledge-base migration、legacy migration
Execution scope: this is an
f2s-*skill workflow, not a CLI subcommand. Migration targets include:
- Structure layer:
.Knowledge/topics,.Knowledge/index.md,.Knowledge/manifest-routing.json,.Knowledge/matchers/*.json- Document layer:
.Knowledge/stock-docs,.Knowledge/req-docsHard boundary:
skills/f2s-*(under each agent configuration root) are Flow2Spec package skills / execution-layer capabilities. They must not be written into.Knowledge(includingtopics/stock-docs/req-docs) and must not be used as sources for "business skill migration". They also must not be deleted in this workflow (version alignment is handled byflow2spec init/ package upgrade).Baseline rule keep-list (must not delete):
rules/f2s-flow2spec-unified-entry.md(c),rules/f2s-implement-tech-design.md(c),rules/f2s-stock-docs-vs-req-docs.md(c).
Orchestration (main / sub-agent)
- The meaning of
subAgent/switchAgentVerificationuses the unified entry as the only source of truth: Cursor/Claude read the configuration-rootrules/f2s-flow2spec-unified-entry.*; Codex reads.codex/topics/f2s-flow2spec-unified-entry.md(same source, mirrored byflow2spec init). This section does not repeat those definitions. - Sub-agent responsibility (only when
subAgent=true): under the main agent's given inventory, perform moving work and generate draft fragments formigration-report.md; all outputs are submitted as patches and merged/written by the main agent. - Main agent must control:
.Knowledge/.migrate-state.jsonwrite authority belongs to main (state-machine source of truth; concurrent main/sub writes can misalign queues).- The "Deletion execution record" section of
migration-report.mdis always appended by the main agent. - Deletion-list confirmation and closed-loop cleanup must be completed by the main agent.
- Write-authority hard rule:
manifest-routing.json/.Knowledge/index.md/.Knowledge/.migrate-state.json/ the migration report "Deletion execution record" are always written by the main agent. - By default, the writing side verifies its own work; this SKILL does not bind cross-agent verification.
f2s-kb-migrate (Legacy Knowledge Base -> New Knowledge Base)
Why this coexists with f2s-kb-upgrade
| Skill | Problem solved |
|---|---|
This skill f2s-kb-migrate |
One-time structural move: legacy indexes (docs-index.md / index-doc.md), rules/main.md(c), business skills/, scattered stock-docs/req-docs -> .Knowledge, plus deletion list and migration-report.md. |
f2s-kb-upgrade |
Knowledge-base template upgrade skill (the only "upgrade" meaning): execute the full skills/f2s-kb-upgrade/SKILL.md workflow. It runs flow2spec init inside the process to align manifest-routing + matchers/ and each agent's rules/skills. It includes V1 / current repository (V2+) branching (legacy projects must migrate first, then run this skill; V2+ includes npm v3.x and other projects already using .Knowledge, see f2s-kb-upgrade step 0). |
- After migration acceptance and deletion-list confirmation are complete: remind the user to execute, or execute for them, the full
f2s-kb-upgradeskill (whose step 2 runsflow2spec init) to align the Flow2Spec package version, routing shards, and configuration-root artifacts to the current package. Do not let the user think that runninginitalone completes knowledge-base template upgrade. - Projects already stably using
.Knowledgewith no legacy-index burden: do not run this skill again; daily package/template alignment usesf2s-kb-upgradeonly (not justinit).
Why does each agent directory have a same-named SKILL.md? Each tool reads only its own configuration-root skills/; flow2spec init syncs the current-language skill content into the selected agent directories.
What This Command Does (External Wording)
Move the legacy "scattered configuration-root document index + rules + business skills + stock/req document trees" as a whole into the new .Knowledge, then perform legacy entry and legacy business-artifact cleanup, cutting over from the old knowledge-base organization.
Objects that must be covered:
- Index entry: business docs and rule clues declared/mapped in configuration-root
docs-index.md(compatible withindex-doc.md). - Rule entry: the rule set declared/referenced in
rules/main.md/rules/main.mdc(common legacy form) orrules/f2s-flow2spec-unified-entry.md/rules/f2s-flow2spec-unified-entry.mdc(compatible with historicalrules/flow2spec-unified-entry.md(c)), plus other business rule files underrules/. - Business skills: business skill directories under each agent configuration-root
skills/, excludingf2s-*(full inventory). - Document trees: legacy
stock-docs/,req-docs/(or synonymous directories) fully migrated into the corresponding.Knowledgedirectories.
For objects not covered by the index:
- First output a candidate list (path + inferred reason: naming/directory/reference relationship).
- By default, user confirmation is required before including them in migration. Only when evidence is very strong (for example explicitly referenced by
rules/main/f2s-flow2spec-unified-entry, or clearly referenced by an indexed document) may the Agent decide to include them, and the basis must be written in the migration summary.
Cleanup after migration (mandatory closing; only when migration has no failures and no pending confirmations; skills/f2s-* are never deleted):
- Must execute: delete migrated business rule files in legacy
rules/(includingmain.md(c)if it is only a legacy entry), but must not delete the threef2s-*root rule files in the baseline keep-list. - Must execute: delete migrated business subdirectories under legacy
skills/(excludingf2s-*; if a directory still has unmigrated items, do not delete it until completed or removed from the list). - Must execute: delete legacy entry
docs-index.md(compatible withindex-doc.md) to avoid dual entry points with.Knowledge/index.md. - Default optional deletion sub-list (the user may exclude): legacy
stock-docs/andreq-docs/source directories, only when the corresponding document-layer migration has passed acceptance with no failures and no pending confirmations.
Meaning of user confirmation (important):
- This is not asking "whether to clean up"; cleanup is part of the workflow.
- Instead, output the default-selected "deletion path list" (rule files one by one, business skill directories one by one, index filenames, and optional legacy document root directories) and ask the user to review. The user can only:
- Reply "确认清单" to delete according to the current list; or
- Reply "排除:<路径…>" to remove specified items from the list before deletion (removed items must be written to
.migrate-state.jsonnotes[]with reasons).
- If the user asks to defer deleting a path, keep that item in the list, end the cleanup round with
status=paused, and do not pretend migration closure is complete.
Applicable Scenarios
- The project still uses legacy knowledge organization (
docs-index.md/index-doc.md+rules/main.md(c)orrules/f2s-flow2spec-unified-entry.md(c)(compatible with oldflow2spec-unified-entry.md(c)) + businessskills/+ scatteredstock-docs/req-docs). - The user wants to migrate to the new
.Knowledgeformat and confirm topic by topic to avoid one-shot large changes. - The user needs all req-docs / stock-docs migrated into
.Knowledgeand wants to cut over from legacy knowledge-base directories/wording (paths, index, topic text unified to the new architecture).
Input
- Optional inputs:
- Legacy unified rule entry path:
rules/main.md/rules/main.mdcand/orrules/f2s-flow2spec-unified-entry.md/rules/f2s-flow2spec-unified-entry.mdc(compatible with oldrules/flow2spec-unified-entry.md(c)) - Legacy
index-doc.md(ordocs-index.md) path - Legacy stock document directory (for example
stock-docs/,docs/stock/) - Legacy requirement document directory (for example
req-docs/,docs/req/) - Migration scope (all topics / specified topics)
- Legacy unified rule entry path:
- If not provided, locate the above files in the repository first and ask the user to confirm.
Resumable Migration State File (Required)
- State file path:
.Knowledge/.migrate-state.json - Purpose: record migration progress and support recovery after session interruption without migrating completed items again.
- Initialization timing: create immediately after the user confirms "start migration".
- Ending timing:
- All migration complete and user confirms completion: delete the state file.
- User actively says "stop": keep the state file for later recovery.
.migrate-state.jsonis written only by the main agent; sub-agents submit patch fragments for the main agent to merge (write-authority hard rule).
Recommended fields (minimal set):
{
"version": "1",
"status": "running",
"currentStage": "inventory|orphans|topics|stock-docs|req-docs|cleanup",
"topicQueue": [],
"topicDone": [],
"bizRuleQueue": [],
"bizRuleDone": [],
"bizSkillQueue": [],
"bizSkillDone": [],
"stockQueue": [],
"stockDone": [],
"reqQueue": [],
"reqDone": [],
"pendingManual": [],
"failed": [],
"notes": [],
"updatedAt": "ISO-8601"
}
Update rules (required):
- After completing each topic, business skill directory, business rule file, or document file, immediately write the state-file update.
- When receiving "重试 <topic|file>", roll back that item's state before retrying.
- When receiving "继续", read the state file first and continue from unfinished queues.
- When receiving "停止", write
status=pausedand end this round. - When receiving a resume request, first show a state summary (current stage, remaining counts, failed/pending items) and wait for user confirmation to continue.
Mandatory Flow (Phased Execution)
Step 1: Read Legacy Mappings
- Read
docs-index.md(compatible withindex-doc.md) and extract "business document -> rule/topic" mappings (primary index). - Read
rules/main.md(compatible withmain.mdc) orrules/f2s-flow2spec-unified-entry.md(compatible withf2s-flow2spec-unified-entry.mdc; compatible with oldflow2spec-unified-entry.md(c)) (usually only one exists), and extract module/topic directory clues (cross-check with the index). - Full inventory of business rule files: scan files under
rules/except the following, and buildbizRuleQueue(deduped):- Unified entry:
main.md(c),f2s-flow2spec-unified-entry.md(c),flow2spec-unified-entry.md(c)(compatible with old name) - Baseline keep:
f2s-implement-tech-design.md(c),f2s-stock-docs-vs-req-docs.md(c)
- Unified entry:
- Full inventory of business skills: scan each agent configuration-root
skills/directory; excludef2s-*; all other directories enterbizSkillQueue(deduped). - Scan legacy
stock-docsandreq-docscandidate source directories if they exist. - Generate the migration inventory and show it to the user for confirmation:
- Topic list (deduped, sorted)
- Business rule file list (
bizRuleQueue) - Business skill directory list (
bizSkillQueue) stock-docsfile listreq-docsfile list
- Document classification rules (must be explicit):
- Source path matches
stock-docs(including synonyms such asdocs/stock) -> migrate to.Knowledge/stock-docs - Source path matches
req-docs(including synonyms such asdocs/req) -> migrate to.Knowledge/req-docs - Unclassifiable files -> put into "manual confirmation list"; do not migrate before confirmation
- Source path matches
- Compute "out-of-index candidates" (
orphans):- Files in
bizRuleQueuenot covered bydocs-index/ unified entry (rules/mainorf2s-flow2spec-unified-entry) - Directories in
bizSkillQueuenot covered by index mappings - By default, require user confirmation for every item; only in high-confidence reference scenarios may the Agent include it autonomously, and the basis must be appended to state-file
notes[](without breaking JSON parseability).
- Files in
- After the user confirms the inventory, initialize the state file and write queues (inventory/orphans/topics/stock/req).
Step 2: Migrate Topic by Topic (Structure-Layer Core)
For each topic, execute in this order:
- Collect legacy materials for the topic:
- Related
rules/*.md(c)(business rules) - Related business
skills/<non-f2s-*>(merge their content into the topic narrative/workflow; do not copy them as skill files under.Knowledge) - Business document paths in index mappings
- Must not include any file under
skills/f2s-*
- Related
- Generate or update
.Knowledge/topics/<topic>.md:- Body text uses the new architecture vocabulary (
.Knowledgelayering,manifestrouting,stock-docs/req-docsresponsibilities). - Remove legacy-only paths/terms (such as old
docs-indexroot paths or scattered legacy directory names) and replace them with.Knowledge/...or stable paths relative to.Knowledge. - Authoring-side guideline: if this step generates/rewrites a topic or adjusts
topicMetadata/topicDependencies, first Read the fullrules/f2s-topic-authoring.*(Cursor/Claude:rules/f2s-topic-authoring.mdc; Codex:.codex/topics/f2s-topic-authoring.md) before writing.
- Body text uses the new architecture vocabulary (
- Update the topic index row in
.Knowledge/index.md, and maintain the "Associated documents (summary)" column (1-3 keystock-docs/req-docsclickable Markdown links per topic, format:[title](relative path)). - Update the routing manifest as needed:
.Knowledge/manifest-routing.json:topicPaths,taskToTopicRules[],topicDependencies,topicMetadata,fallbackTopic.Knowledge/matchers/<matcherId>.json:includeAny(consistent withmanifest-routing.taskToTopicRules[].matcherPath)
- Output this topic's migration summary and pause, prompting the user:
- Reply "继续" to migrate the next topic
- Or reply "停止" to stop this round
- Or reply "重试
" to redo the current topic
Before receiving "继续", do not migrate the next topic. After completing each topic, update the state file before waiting.
Step 3: Migrate stock-docs (Document Layer)
After step 2 completes, execute:
- Migrate into
.Knowledge/stock-docs/<relative-path>according to "source-directory relative path"; do not flatten. - Default scenario is first migration from a legacy repo into the new knowledge base, so target paths are treated as "not existing".
- After each file migration, output a result and pause, waiting for "继续 / 停止 / 重试 <文件>".
- After all files complete, output a
stock-docssub-summary (success/failure/pending confirmation).
Before receiving "继续", do not migrate the next file. After completing each file, update the state file before waiting.
Step 4: Migrate req-docs (Document Layer)
After the stock-docs phase completes, execute:
- Migrate into
.Knowledge/req-docs/<relative-path>according to "source-directory relative path"; do not flatten. - Default scenario is first migration from a legacy repo into the new knowledge base, so target paths are treated as "not existing".
- After each file migration, output a result and pause, waiting for "继续 / 停止 / 重试 <文件>".
- After all files complete, output a
req-docssub-summary (success/failure/pending confirmation).
Before receiving "继续", do not migrate the next file. After completing each file, update the state file before waiting.
Step 5: Closing After All Migration Completes (Required: Migration Report + Deletion-List Confirmation)
When topic migration (step 2) and document-layer stock-docs / req-docs migration (steps 3-4) have all passed acceptance (no failures and no blocking pending confirmations, or pending items are separately listed in the report), execute the following substeps in order.
5.0 Migration Report (Required: Write Project Markdown)
- Must create or overwrite this file in the project repository:
.Knowledge/migration-report.md(relative to project root; same repo as.Knowledge, convenient for review and traceability). - The report body must contain at least two major blocks (tables or nested lists are allowed; all paths use POSIX style relative to project root):
- "Migration mapping table":
- Topics: each migrated
topic-> legacy sources (correspondingrules/*.md(c), businessskills/<dir>,docs-indexmapping-line summary) -> new path.Knowledge/topics/<topic>.md; also indicate whether.Knowledge/index.md/ routing-manifest fields were modified. stock-docs: every source path ->.Knowledge/stock-docs/...target path (include skipped files and reasons; write "none" if none).req-docs: same as above.
- Topics: each migrated
- "Proposed deletion path list": exactly consistent with the default-selected deletion list shown to the user in step 5.2 (each file under
rules/, each businessskills/directory to delete,docs-index/index-doc, and optionally legacystock-docs//req-docs/roots). Prefer- [ ] <path>for each item so humans can review/check.
- "Migration mapping table":
- If the user later sends "排除:<路径…>" in step 5.2, update the same file before physical deletion: append or write in a "User exclusions" section the excluded paths and reasons, and sync the "Proposed deletion path list" checkbox state or list so the report on disk matches the final deletion set.
- After physical deletion is executed according to the final list in step 5.2 step 3, append a
## Deletion Execution Recordsection at the end of the same file (include execution time and actual deleted paths; for undeleted items, state reason andstatus=paused, etc.). Do not leave this only in the conversation. - The migration report "Deletion execution record" section is always appended by the main agent; sub-agents must not write it directly (write-authority hard rule).
Forbidden: entering physical deletion or ending the migration closure before
.Knowledge/migration-report.mdis written.
5.1 Overall Summary (In Conversation, May Match Report Summary)
- Migrated topic list
- New/updated
.Knowledgefiles - Migrated
stock-docsfiles - Migrated
req-docsfiles - Unmigrated or failed items
5.2 Required Cleanup Phase (Deletion-List Confirmation; Must Not Skip)
- Output the default-selected "deletion path list" (same source as the "Proposed deletion path list" in
migration-report.md), including at least:- Every business rule file path under legacy
rules/to delete (may includemain.md(c); must not include the baselinef2s-*root rules) - Every subdirectory path under legacy business
skills/to delete (excludingf2s-*) - Legacy
docs-index.md/index-doc.md - (Optional sub-list) legacy
stock-docs/andreq-docs/root directories, only when document migration has passed acceptance and no pending items remain; the user may exclude them.
- Every business rule file path under legacy
- Wait for the user to reply "确认清单" or "排除:<路径…>" to update the list. Do not ask a binary "whether to clean up" question.
- Delete according to the final list; do not delete paths outside the list; do not delete
skills/f2s-*. - After closing is complete, handle the state file:
- Fully completed round: delete
.Knowledge/.migrate-state.json - Paused/aborted round: keep
.Knowledge/.migrate-state.json(status=paused) and record undeleted paths and reasons
- Fully completed round: delete
Output Summary Format (Recommended)
## Topic Migration Complete: <topic>
### Sources
- rules: <legacy paths...>
- business docs: <document paths from index mappings...>
- mapping: <docs-index / index-doc row or document name>
### Written
- .Knowledge/topics/<topic>.md
- .Knowledge/index.md (updated <x> rows)
- .Knowledge/manifest-routing.json (updated fields: ...)
- .Knowledge/matchers/<id>.json (updated `includeAny`, etc.: ...)
### Next Step
- Reply "继续" to migrate the next topic
- Reply "停止" to stop migration
## Document Migration Complete: <stock-docs|req-docs>/<file>
### Source
- source: <legacy path...>
### Written
- .Knowledge/<stock-docs|req-docs>/<relative-path>
### Next Step
- Reply "继续" to migrate the next file
- Reply "停止" to stop migration
Constraints
- Must confirm topic by topic; do not skip confirmation and migrate everything in batch.
stock-docs/req-docsmust confirm file by file; do not batch-migrate without confirmation.- Document migration must preserve source-directory relative paths; do not flatten to single-layer filenames.
f2s-*skills must not enter.Knowledgeand must not be merged into topics during topic migration.- Business
skills/(non-f2s-*) must be fully inventoried; out-of-index items require user confirmation by default before migration. - Before all topics complete, do not delete legacy business
rules/or old businessskills/that are non-f2s-*; the baselinef2s-*root rule files are never deleted. - Before document migration completes, do not delete legacy document directories.
- Before deleting legacy directories, complete "deletion path list" review (exclusions allowed); do not replace list confirmation with "whether to clean up".
- During migration, modify only
.Knowledgeand (after final deletion-list confirmation) deletion of old paths in the list; do not modify business code. - Must maintain
.Knowledge/.migrate-state.json; do not keep migration progress only in memory. - After topic and document-layer migration acceptance, first write
.Knowledge/migration-report.md(including migration mapping table and proposed deletion path list), then enter physical deletion; report and in-conversation deletion list must share a traceable source. .migrate-state.json/migration-report.mddeletion execution record /manifest-routing.json/.Knowledge/index.mdare always written by the main agent.
Migration Report Template (Recommended Structure for migration-report.md)
The following skeleton may be copied and filled; all paths are relative to project root.
# Knowledge-Base Migration Report
- **Generated at (ISO-8601)**: <...>
- **Configuration root (for example `.cursor/`)**: <...>
## Migration Mapping Table
### Topics (legacy sources -> new path)
| topic ID | legacy rules / legacy business skills / index clues | new path |
| --- | --- | --- |
| <id> | <...> | `.Knowledge/topics/<id>.md` |
### stock-docs (source -> target)
| source path | target path | note |
| --- | --- | --- |
| <...> | `.Knowledge/stock-docs/...` | success / skip reason |
### req-docs (source -> target)
| source path | target path | note |
| --- | --- | --- |
| <...> | `.Knowledge/req-docs/...` | success / skip reason |
## Proposed Deletion Path List (default selected; same as in-conversation list)
- [ ] `<path>` (each file under `rules/`)
- [ ] `<path>` (business `skills/<dir>`, excluding `f2s-*`)
- [ ] `.cursor/docs-index.md` (or actual path)
- [ ] (optional) legacy `stock-docs/` / `req-docs/` root directories
## User Exclusions (if any)
- (write "none" if none)
## Failed or Unmigrated Items (if any)
- (write "none" if none)
## Deletion Execution Record
(Append only after physical deletion: time, deleted list, undeleted items and reasons)
Completion Self-Check
- Topic count aligns with the legacy mapping count (unless the user explicitly skipped items).
- Every
manifest.topics[].pathexists. indexcan locate every migrated topic.topicMetadataonly references topicIds that exist intopicPaths;primary/tags/confidenceare valid..Knowledge/stock-docsand.Knowledge/req-docsmatch the confirmed migration lists.- Manual confirmation list is empty; if not, deleting legacy document directories is forbidden.
- Legacy business
rules/, old businessskills/that are non-f2s-*, legacy indexes, and legacy document directories (if listed) were deleted according to the final deletion list; the threef2s-*root rules in the baseline keep-list are still kept. - Legacy entries
docs-index.md/index-doc.mdandrules/main.md(c)were deleted according to the list (and.Knowledgecan replace their responsibilities), or explicitly kept due to user exclusion and written tonotes[]. - State file matches migration result (delete if complete; keep with
status=pausedif paused). .Knowledge/index.mdhas synced the "Associated documents (summary)" column for every topic (may write "none", but not blank).skills/f2s-*were not accidentally deleted and were not written into.Knowledge..Knowledge/migration-report.mdis written and contains the migration mapping table and proposed deletion path list; if deletion was executed,## Deletion Execution Recordwas appended and matches actual disk state.- State-machine file and deletion execution record were not written by sub-agents without authority; manifest / index were written by the main agent only.