[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M752RXVDVDMFHXGAQ7S7C10J":3,"skill-same:01M752RXVDVDMFHXGAQ7S7C10J":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M752RXVDVDMFHXGAQ7S7C10J","consolidate-code",null,"Incremental deduplication workflow: map overlapping implementations, plan a PR stack into shared packages, seal doctests, migrate callers without behavior change. Use when the user mentions consolidate, dedupe, shared package, move enrichment into dot-pkgs, eliminate duplication, or \u002Fconsolidate-code. Pair with investigate (overlap map) and doctest-tdd (sealed tests → impl).","xhd2015\u002Fagent-pro","xhd2015","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F14964938?v=4","01M752R5K679TBRT2X43X9RYCR","01M752R5MBCWS6252YZW22Y49W",1,"MIT","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Fconsolidate-code\u002Frun\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: consolidate-code\ndescription: >-\n  Incremental deduplication workflow: map overlapping implementations, plan a\n  PR stack into shared packages, seal doctests, migrate callers without behavior\n  change. Use when the user mentions consolidate, dedupe, shared package,\n  move enrichment into dot-pkgs, eliminate duplication, or \u002Fconsolidate-code.\n  Pair with investigate (overlap map) and doctest-tdd (sealed tests → impl).\n---\n\nYou guide the agent through **safe, incremental code consolidation** — extracting\nduplicated logic into shared packages while preserving caller-facing behavior.\nThe goal is one canonical implementation per concern, with rerunnable regressions\nproving nothing broke.\n\n# When to use\n\n- Same concern implemented in 2+ places (git subprocess, porcelain parse, enrichment)\n- A feature repo reinvented utilities that already exist in a shared module\n- User wants PR-sized consolidation (not a big-bang refactor)\n- After `investigate` identified overlap and user asked to fix it\n\n# When not to use\n\n- Greenfield feature with no duplication to merge\n- Doc-only or comment-only changes\n- Behavior change is intentional — use `brainstorm` + `doctest-tdd` as a feature\n- User only wants root-cause explanation → `investigate` alone\n\n# Related skills\n\n| Skill | Role in consolidation |\n|-------|----------------------|\n| `investigate` | Map duplication matrix before moving code |\n| `brainstorm` \u002F `followup` | Lock API shapes and PR boundaries with user |\n| `doctest-tdd` | Designer → RED → seal → implementer (orchestrator never edits `.go`) |\n| `doctest-tdd-lite` | Single-agent TDD when overlap is small and localized |\n| `explore` | Fast grep\u002Fread pass to find all copies of a pattern |\n\n# Required workflow\n\n## Phase 1 — Overlap map (investigate)\n\nBuild a **concern matrix** before writing code:\n\n| Concern | Locations (absolute paths) | API differences | Callers | Consolidation target |\n|---------|---------------------------|-----------------|---------|---------------------|\n\n**Gather evidence**\n\n- `rg` for identical patterns (`gitOutput`, `parsePorcelain`, `exec.Command(\"git\"`)\n- Read each copy; note semantic differences (e.g. wrk `changed` vs backup `modified`)\n- List doctest\u002Funit regressions that lock current behavior per caller\n\n**Classify each concern**\n\n- **Merge** — same semantics → one shared function\n- **Parameterize** — same parser, different format\u002Ftaxonomy → `FormatStyle` or parallel types (`WrkCounts` vs `Counts`)\n- **Keep separate** — different jobs (mutating git + verbose log vs read-only `git\u002Fcmd`)\n- **Defer** — next PR; document in REQUIREMENT-DESIGN\n\n**Response slice:** Observation → Findings table → recommended PR stack.\n\n## Phase 2 — PR stack plan\n\nSplit into **foundation → callers → domain glue**. Typical order:\n\n1. **Foundation** — lowest layer with no caller imports (`git\u002Fcmd`, parsers, types)\n2. **Mid-layer** — composes foundation (`git\u002Fcheckout.Enrich`, `git\u002Freposnapshot.Build`)\n3. **First caller migration** — highest-value duplicate removed; regressions pass\n4. **Remaining callers** — wrkcli, scan_repo, worktree, app server package\n5. **Delete dead code** — only after all callers migrated\n\nEach PR must:\n\n- Preserve stdout\u002FJSON\u002FAPI contracts unless explicitly changing behavior\n- State what stays in the caller (ANSI color, summary layout, CLI flags)\n- Name locked decisions in a table (taxonomy, error durability, path callbacks)\n\nWrite `REQUIREMENT-DESIGN-\u003Cslug>.md` per PR. Get user `\u002Fgo ahead` before TDD.\n\n## Phase 3 — Test strategy (before implementation)\n\n**Prefer doctest leaves** for behavior locked by CLI or subprocess output.\n\n| Layer | Tests |\n|-------|-------|\n| New shared package | `pkg\u002Ftests\u002F` leaves (parse, format, enrich) |\n| Existing CLI | Re-run full existing doctest tree — no new leaves if behavior unchanged |\n| App integration | Targeted regression leaves (e.g. `git-repos-summary`) |\n\nRules:\n\n- Seal tests once (`git add tests\u002F`) — implementer must not modify sealed trees\n- External\u002Fgitignored modules: seal in the **canonical module repo**, not the consumer\n- For CLI stdout: assert ends with trailing newline when using doctest templates\n\n## Phase 4 — Implement (doctest-tdd)\n\nDefault: **orchestrator delegates** — never hand-edit `.go` in TDD mode.\n\n```\ndesigner → doctest vet → doctest test (RED) → git add tests → implementer → GREEN\n```\n\nImplementer checklist:\n\n- Resolve **name collisions** early (const vs function in same package)\n- Route read-only git through shared `cmd.Run`; keep mutating `exec.Cmd` where logging\u002Fstreaming differs\n- Caller wrappers stay thin (color, JSON map, summary section headers)\n- **Durable enrichment** — partial fields + per-step `error`; never fail whole scan for one bad repo\n\n## Phase 5 — Verify\n\n```sh\ndoctest vet .\u002F\u003Cnew-test-tree>\ndoctest test .\u002F\u003Cnew-test-tree>\u002F...\ndoctest test .\u002F\u003Ccaller-regression-trees>\u002F...\ngo test .\u002F\u003Caffected-packages>\u002F... -count=1\ngit diff .\u002F\u003Csealed-test-tree>   # must be clean\n```\n\nReport: pass counts, lines removed per file, accepted test amendments (with rationale).\n\n# Consolidation patterns (proven)\n\n| Pattern | Example |\n|---------|---------|\n| Subprocess layer | `git\u002Fcmd.Run` replaces private `gitOutput` in N packages |\n| Parser + formatter split | `ParsePorcelain` + `Format(Backup)`; wrk gets `ParsePorcelainWrk` + `FormatWrk` |\n| Options struct | `checkout.Options{StatusStyle, PorcelainUntracked}` for caller variants |\n| Export list parser | `worktree.ParseListPorcelain`; `scan_repo` calls `worktree.ListCtx` |\n| Domain glue stays up-stack | `machinebackup` keeps JSON version + `GIT REPOS:` summary layout |\n| Is-clean helper | `worktree.IsCleanWrk` — wrkcli delegates instead of inline parse |\n\n# Anti-patterns\n\n- Big-bang delete-then-fix across repos\n- Merging different semantics because strings look similar\n- Moving ANSI\u002FCLI formatting into shared packages\n- Modifying sealed doctests to match a wrong implementation\n- Skipping caller regressions because unit tests pass\n\n# Response shape\n\n1. **Overlap summary** — concern matrix (or PR-N scope if continuing a stack)\n2. **PR plan** — ordered list with in\u002Fout of scope per PR\n3. **Locked decisions** — table (API, taxonomy, what stays in caller)\n4. **Test plan** — new leaves + regression commands\n5. **Next action** — `REQUIREMENT-DESIGN` draft or spawn designer (after user go-ahead)\n\n# Commands\n\n```sh\nagent-pro skill consolidate-code --show\nagent-pro skill consolidate-code install\nagent-pro skill investigate --show\nagent-pro skill doctest-tdd --show    # if installed in .agents\u002Fskills\u002F\n```\n\n# Case study (dot-pkgs git stack)\n\nPR-1–4: `git\u002Fcmd`, `git\u002Fstatus`, `git\u002Fcheckout`, `git\u002Freposnapshot` ← `machinebackup\u002Fgit_repos.go`\nPR-5: wrkcli → `checkout.Enrich` + `FormatWrk`; 35 wrk status doctests unchanged\nPR-6: `scan_repo` → `worktree.ListCtx`; `IsCleanWrk`; deleted duplicate parsers\n\nLesson: wrk and backup **share subprocess and parse machinery** but **not format strings**.","You guide the agent through **safe, incremental code consolidation** — extracting\nduplicated logic into shared packages while preserving caller-facing behavior.\nThe goal is one canonical implementation per concern, with rerunnable regressions\nproving nothing broke.\n\n# When to use\n\n- Same concern implemented in 2+ places (git subprocess, porcelain parse, enrichment)\n- A feature repo reinvented utilities that already exist in a shared module\n- User wants PR-sized consolidation (not a big-bang refactor)\n- After `investigate` identified overlap and user asked to fix it\n\n# When not to use\n\n- Greenfield feature with no duplication to merge\n- Doc-only or comment-only changes\n- Behavior change is intentional — use `brainstorm` + `doctest-tdd` as a feature\n- User only wants root-cause explanation → `investigate` alone\n\n# Related skills\n\n| Skill | Role in consolidation |\n|-------|----------------------|\n| `investigate` | Map duplication matrix before moving code |\n| `brainstorm` \u002F `followup` | Lock API shapes and PR boundaries with user |\n| `doctest-tdd` | Designer → RED → seal → implementer (orchestrator never edits `.go`) |\n| `doctest-tdd-lite` | Single-agent TDD when overlap is small and localized |\n| `explore` | Fast grep\u002Fread pass to find all copies of a pattern |\n\n# Required workflow\n\n## Phase 1 — Overlap map (investigate)\n\nBuild a **concern matrix** before writing code:\n\n| Concern | Locations (absolute paths) | API differences | Callers | Consolidation target |\n|---------|---------------------------|-----------------|---------|---------------------|\n\n**Gather evidence**\n\n- `rg` for identical patterns (`gitOutput`, `parsePorcelain`, `exec.Command(\"git\"`)\n- Read each copy; note semantic differences (e.g. wrk `changed` vs backup `modified`)\n- List doctest\u002Funit regressions that lock current behavior per caller\n\n**Classify each concern**\n\n- **Merge** — same semantics → one shared function\n- **Parameterize** — same parser, different format\u002Ftaxonomy → `FormatStyle` or parallel types (`WrkCounts` vs `Counts`)\n- **Keep separate** — different jobs (mutating git + verbose log vs read-only `git\u002Fcmd`)\n- **Defer** — next PR; document in REQUIREMENT-DESIGN\n\n**Response slice:** Observation → Findings table → recommended PR stack.\n\n## Phase 2 — PR stack plan\n\nSplit into **foundation → callers → domain glue**. Typical order:\n\n1. **Foundation** — lowest layer with no caller imports (`git\u002Fcmd`, parsers, types)\n2. **Mid-layer** — composes foundation (`git\u002Fcheckout.Enrich`, `git\u002Freposnapshot.Build`)\n3. **First caller migration** — highest-value duplicate removed; regressions pass\n4. **Remaining callers** — wrkcli, scan_repo, worktree, app server package\n5. **Delete dead code** — only after all callers migrated\n\nEach PR must:\n\n- Preserve stdout\u002FJSON\u002FAPI contracts unless explicitly changing behavior\n- State what stays in the caller (ANSI color, summary layout, CLI flags)\n- Name locked decisions in a table (taxonomy, error durability, path callbacks)\n\nWrite `REQUIREMENT-DESIGN-\u003Cslug>.md` per PR. Get user `\u002Fgo ahead` before TDD.\n\n## Phase 3 — Test strategy (before implementation)\n\n**Prefer doctest leaves** for behavior locked by CLI or subprocess output.\n\n| Layer | Tests |\n|-------|-------|\n| New shared package | `pkg\u002Ftests\u002F` leaves (parse, format, enrich) |\n| Existing CLI | Re-run full existing doctest tree — no new leaves if behavior unchanged |\n| App integration | Targeted regression leaves (e.g. `git-repos-summary`) |\n\nRules:\n\n- Seal tests once (`git add tests\u002F`) — implementer must not modify sealed trees\n- External\u002Fgitignored modules: seal in the **canonical module repo**, not the consumer\n- For CLI stdout: assert ends with trailing newline when using doctest templates\n\n## Phase 4 — Implement (doctest-tdd)\n\nDefault: **orchestrator delegates** — never hand-edit `.go` in TDD mode.\n\n```\ndesigner → doctest vet → doctest test (RED) → git add tests → implementer → GREEN\n```\n\nImplementer checklist:\n\n- Resolve **name collisions** early (const vs function in same package)\n- Route read-only git through shared `cmd.Run`; keep mutating `exec.Cmd` where logging\u002Fstreaming differs\n- Caller wrappers stay thin (color, JSON map, summary section headers)\n- **Durable enrichment** — partial fields + per-step `error`; never fail whole scan for one bad repo\n\n## Phase 5 — Verify\n\n```sh\ndoctest vet .\u002F\u003Cnew-test-tree>\ndoctest test .\u002F\u003Cnew-test-tree>\u002F...\ndoctest test .\u002F\u003Ccaller-regression-trees>\u002F...\ngo test .\u002F\u003Caffected-packages>\u002F... -count=1\ngit diff .\u002F\u003Csealed-test-tree>   # must be clean\n```\n\nReport: pass counts, lines removed per file, accepted test amendments (with rationale).\n\n# Consolidation patterns (proven)\n\n| Pattern | Example |\n|---------|---------|\n| Subprocess layer | `git\u002Fcmd.Run` replaces private `gitOutput` in N packages |\n| Parser + formatter split | `ParsePorcelain` + `Format(Backup)`; wrk gets `ParsePorcelainWrk` + `FormatWrk` |\n| Options struct | `checkout.Options{StatusStyle, PorcelainUntracked}` for caller variants |\n| Export list parser | `worktree.ParseListPorcelain`; `scan_repo` calls `worktree.ListCtx` |\n| Domain glue stays up-stack | `machinebackup` keeps JSON version + `GIT REPOS:` summary layout |\n| Is-clean helper | `worktree.IsCleanWrk` — wrkcli delegates instead of inline parse |\n\n# Anti-patterns\n\n- Big-bang delete-then-fix across repos\n- Merging different semantics because strings look similar\n- Moving ANSI\u002FCLI formatting into shared packages\n- Modifying sealed doctests to match a wrong implementation\n- Skipping caller regressions because unit tests pass\n\n# Response shape\n\n1. **Overlap summary** — concern matrix (or PR-N scope if continuing a stack)\n2. **PR plan** — ordered list with in\u002Fout of scope per PR\n3. **Locked decisions** — table (API, taxonomy, what stays in caller)\n4. **Test plan** — new leaves + regression commands\n5. **Next action** — `REQUIREMENT-DESIGN` draft or spawn designer (after user go-ahead)\n\n# Commands\n\n```sh\nagent-pro skill consolidate-code --show\nagent-pro skill consolidate-code install\nagent-pro skill investigate --show\nagent-pro skill doctest-tdd --show    # if installed in .agents\u002Fskills\u002F\n```\n\n# Case study (dot-pkgs git stack)\n\nPR-1–4: `git\u002Fcmd`, `git\u002Fstatus`, `git\u002Fcheckout`, `git\u002Freposnapshot` ← `machinebackup\u002Fgit_repos.go`\nPR-5: wrkcli → `checkout.Enrich` + `FormatWrk`; 35 wrk status doctests unchanged\nPR-6: `scan_repo` → `worktree.ListCtx`; `IsCleanWrk`; deleted duplicate parsers\n\nLesson: wrk and backup **share subprocess and parse machinery** but **not format strings**.",{"name":5,"description":7},"master","d5d5361083d4adf0dd8a15272123af778b38117a","agents\u002Fconsolidate-code\u002Frun",0,"https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro","https:\u002F\u002Fgithub.com\u002Fxhd2015","https:\u002F\u002Fblog.xhd2015.xyz","@Harbin Institute of Technology","2026-11-12 07:05:51",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add xhd2015\u002Fagent-pro --skill consolidate-code",{"tool":38,"command":39},"bunx","bunx skills add xhd2015\u002Fagent-pro --skill consolidate-code",{"tool":41,"command":42},"pnpm","pnpm dlx skills add xhd2015\u002Fagent-pro --skill consolidate-code","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Fconsolidate-code\u002Frun\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"consolidate_code.go","SCRIPT","脚本",71,"https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Fconsolidate-code\u002Frun\u002Fconsolidate_code.go",[53,60,67,74,81,88],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":18},"01M752V7X3HGMWGCPSWMG498TY","verify-with-prototype","Prototype-before-production workflow for risky host integrations (sudo, privileges, system config). Use when a feature touches the real OS, when behavior must be proven with a small script before full implementation, or when the user mentions prototype verification, POC script, or verify-with-prototype. Run after investigate\u002Ffollowup and before doctest-TDD integration.","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Fverify-with-prototype\u002Frun\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M752V363XA61Q2PSVS0W9M3H","verify-on-behalf-of-user","Run human-style scenario verification after an agent claims work is done: git status, build into ~\u002F.sandbox\u002Fbin (default sandbox mode) or opt-in host mode (outside sandbox: wrk --reinstall-local \u002F change-scoped install), real integration\u002FE2E scenarios (start servers, browser-agent for UI), always-labeled depth, markdown transcript written and inlined for review. Use for \"verify on my behalf\", before commit. Complements doctests; does not replace them. Load a sub-topic with: agent-pro skill --show verify-on-behalf-of-user\u002F\u003Ctopic>","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Fverify-on-behalf-of-user\u002Frun\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M752TVN3Y9ZMKW52A8MKZ3QP","test-case-tree-design-expert","Use when the user wants a decision-tree style test case design with inherited setup and per-leaf assertions.","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Ftest-case-tree-design-expert\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":18},"01M752TSECEXD80J650BC6YXMY","test-case-design-expert","Use when the user wants comprehensive user-facing end-to-end test scenarios for a feature description.","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Ftest-case-design-expert\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M752TQB00WQJ9475GF0JVEGY","tdd-expert","Use when the user has a test-case-tree output and wants runnable Go tests plus stub implementation following Test-Driven Development.","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Ftdd-expert\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":18},"01M752TGQ1905Y0FTCTQPMJTA7","summarize-a-skill","Meta-skill: distill durable high-signal guidance (worked vs failed, wrong → correct, and anything else that quickens future similar tasks) into a brief reusable skill document with YAML frontmatter. When the user does not explicitly ask for a new skill\u002Ffile, prefer updating an existing skill over creating one. Writes skills\u002F\u003Cname>\u002FSKILL.md (or docs|doc\u002Fskills\u002F…). Use for \u002Fsummarize-a-skill, \"summarize what worked\", \"lessons learned into a skill\", or \"write a skill from this session\".","https:\u002F\u002Fgithub.com\u002Fxhd2015\u002Fagent-pro\u002Fblob\u002Fmaster\u002Fagents\u002Fsummarize-a-skill\u002Frun\u002FSKILL.md",[],[]]