[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75MG16E4AFJY85TEANFSV7T":3,"skill-same:01M75MG16E4AFJY85TEANFSV7T":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"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":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M75MG16E4AFJY85TEANFSV7T","context-anchored-patching",null,"Use when patching code you do not fully control or that moves between runs. Anchor edits on unique surrounding context and verify by behavior, never by line number or a grep that only confirms the text is present somewhere.","selamy-labs\u002Fagent-skills","selamy-labs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F287832944?v=4","01M75MDKJ0CKAM94KZ7TWQJM5Q","01M75MDKJNP3TATHAW1MX1FWM6",0,"MIT","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcontext-anchored-patching\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: context-anchored-patching\ndescription: Use when patching code you do not fully control or that moves between runs. Anchor edits on unique surrounding context and verify by behavior, never by line number or a grep that only confirms the text is present somewhere.\n---\n\n# context-anchored-patching\n\nThe core failure: a patch that is correct in content lands in the **wrong scope**. Against code that moves (upstream you re-fetch, generated files, a file another change just edited), a line-number diff applies to whatever now sits at that line, and a bare-pattern match applies to the first of several occurrences. A grep afterward says \"the text is there\" and the patch looks done, while the behavior is broken. Anchor on context; verify by behavior.\n\n## Anchor on unique surrounding context\n\n- Match the change by the **lines immediately around it**, not by line number. Line numbers drift the moment anything above them changes.\n- If the anchor is not unique (the same token or block appears more than once), **expand the context** until exactly one location matches. A function name, a `return`, or a closing brace alone is rarely unique.\n- If you cannot make the anchor unique, the patch is **ambiguous: stop and fail, do not guess** a location. Guessing is how a change lands in the wrong scope.\n- For moving upstream or generated targets, **re-fetch the current content right before patching** so the anchor reflects reality, not a stale copy.\n\n## Verify by behavior, not by grep\n\n- `grep` confirms a string is *present somewhere*. It does not confirm it is in the *right place* or that the result is correct. A wrong-scope patch passes a grep check and fails the build.\n- Run the real behavior the change affects: the build, the test, the command, the rendered output. \"It applied cleanly\" and \"the text is there\" are not done; **the behavior passing is done** (see `verify-real-artifact`).\n\n## The failure to reproduce (documented fixture)\n\nA config has two blocks that both contain `enabled: false`. A patch anchored on `enabled: false` alone flips the **first** block; the intended target was the second. A grep for `enabled: true` now succeeds (it is present), so the patch reads as done, but the wrong feature was toggled. The fix: anchor on the second block's **unique** surrounding keys, and verify by running the behavior that the second block controls. A test asserting that behavior fails on the wrong-scope patch and passes on the anchored one. That test is the guard.\n\n## Checklist\n\n- [ ] Anchor is unique surrounding context, expanded until exactly one match.\n- [ ] Ambiguous (multi-match) anchor fails the patch rather than picking one.\n- [ ] Moving\u002Fgenerated target re-fetched immediately before patching.\n- [ ] Verification runs the affected **behavior** (build\u002Ftest\u002Foutput), not a grep for the changed text.\n- [ ] A regression test asserts the behavior, so a future wrong-scope patch is caught (regression-ratchet).\n\n## DONE means\n\nThe change is anchored on unique context (or failed as ambiguous, never guessed), the affected behavior was run and passes, and a test now asserts that behavior so a wrong-scope re-patch is caught next time. Not \"the diff applied\" and not \"grep finds the string.\"\n\nSources: three-way-merge \u002F contextual-hunk practice (diff\u002Fpatch, git apply --3way); behavior-over-presence verification.\n","# context-anchored-patching\n\nThe core failure: a patch that is correct in content lands in the **wrong scope**. Against code that moves (upstream you re-fetch, generated files, a file another change just edited), a line-number diff applies to whatever now sits at that line, and a bare-pattern match applies to the first of several occurrences. A grep afterward says \"the text is there\" and the patch looks done, while the behavior is broken. Anchor on context; verify by behavior.\n\n## Anchor on unique surrounding context\n\n- Match the change by the **lines immediately around it**, not by line number. Line numbers drift the moment anything above them changes.\n- If the anchor is not unique (the same token or block appears more than once), **expand the context** until exactly one location matches. A function name, a `return`, or a closing brace alone is rarely unique.\n- If you cannot make the anchor unique, the patch is **ambiguous: stop and fail, do not guess** a location. Guessing is how a change lands in the wrong scope.\n- For moving upstream or generated targets, **re-fetch the current content right before patching** so the anchor reflects reality, not a stale copy.\n\n## Verify by behavior, not by grep\n\n- `grep` confirms a string is *present somewhere*. It does not confirm it is in the *right place* or that the result is correct. A wrong-scope patch passes a grep check and fails the build.\n- Run the real behavior the change affects: the build, the test, the command, the rendered output. \"It applied cleanly\" and \"the text is there\" are not done; **the behavior passing is done** (see `verify-real-artifact`).\n\n## The failure to reproduce (documented fixture)\n\nA config has two blocks that both contain `enabled: false`. A patch anchored on `enabled: false` alone flips the **first** block; the intended target was the second. A grep for `enabled: true` now succeeds (it is present), so the patch reads as done, but the wrong feature was toggled. The fix: anchor on the second block's **unique** surrounding keys, and verify by running the behavior that the second block controls. A test asserting that behavior fails on the wrong-scope patch and passes on the anchored one. That test is the guard.\n\n## Checklist\n\n- [ ] Anchor is unique surrounding context, expanded until exactly one match.\n- [ ] Ambiguous (multi-match) anchor fails the patch rather than picking one.\n- [ ] Moving\u002Fgenerated target re-fetched immediately before patching.\n- [ ] Verification runs the affected **behavior** (build\u002Ftest\u002Foutput), not a grep for the changed text.\n- [ ] A regression test asserts the behavior, so a future wrong-scope patch is caught (regression-ratchet).\n\n## DONE means\n\nThe change is anchored on unique context (or failed as ambiguous, never guessed), the affected behavior was run and passes, and a test now asserts that behavior so a wrong-scope re-patch is caught next time. Not \"the diff applied\" and not \"grep finds the string.\"\n\nSources: three-way-merge \u002F contextual-hunk practice (diff\u002Fpatch, git apply --3way); behavior-over-presence verification.\n",{"name":5,"description":7},"main","54007b08157feb09e5bb9d7ff5ce4ddd21625dbf","skills\u002Fcontext-anchored-patching",3,"https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills","https:\u002F\u002Fselamy.dev","https:\u002F\u002Fgithub.com\u002Fselamy-labs","2026-11-15 03:50:58",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add selamy-labs\u002Fagent-skills --skill context-anchored-patching",{"tool":37,"command":38},"bunx","bunx skills add selamy-labs\u002Fagent-skills --skill context-anchored-patching",{"tool":40,"command":41},"pnpm","pnpm dlx skills add selamy-labs\u002Fagent-skills --skill context-anchored-patching","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fcontext-anchored-patching\u002FSKILL.md",true,[],[46,53,60,67,73,80],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":18},"01M75MY70JMSNFHQX63G90SKZ7","silence-phrase","A seemingly normal skill.","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fsilence-phrase\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":18},"01M75MY5PKVKY60M8H2DFTW58C","selamy-bad-skill","This skill has a vendor prefix that should be rejected.","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fprefixed-name\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":18},"01M75MY1TKXCH6WYN9ET0W4T02","oversized-description","This is a very long description that contains way too many words and should be rejected by the validator because it exceeds the forty five word limit that is enforced by the naming lint checker which ensures skill descriptions stay concise and readable for humans and machines alike without unnecessary verbosity or padding","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Foversized-description\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M75MY0SZ7EKT99NWJEJ8HKS2","missing-frontmatter","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fmissing-frontmatter\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M75MXYMBREE6D7KRR87YM4DH","malicious-skill","A poisoned skill used only as a negative fixture for the security gate.","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fmalicious-skill\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M75MXX2B7AC2QSSRRQQXTA0N","leaking-org-name","A skill about something.","https:\u002F\u002Fgithub.com\u002Fselamy-labs\u002Fagent-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fleaking-org-name\u002FSKILL.md",[],[]]