{"record":{"id":"4f2a88c226a9c07c","repo":"sipeed/picoclaw","slug":"skill-patch-frontmatter-name-q-does-not-match-tar","errorCode":null,"errorMessage":"skill patch frontmatter name %q does not match target skill %q","messagePattern":"skill patch frontmatter name %q does not match target skill %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/evolution/apply.go","lineNumber":228,"sourceCode":"\t\t}, \"\\n\")\n\t\treturn strings.TrimRight(existingBody, \"\\n\") + mergedSection, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported change_kind %q\", draft.ChangeKind)\n\t}\n}\n\nfunc renderDeployablePatchBody(body, targetSkillName string) (string, error) {\n\tbody = renderDeployableSkillBody(body)\n\tfrontmatter, markdownBody := splitSkillFrontmatter(body)\n\tif frontmatter == \"\" {\n\t\tmarkdownBody = body\n\t} else {\n\t\tfields, err := parseSkillFrontmatterFields(frontmatter, true)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif name := strings.TrimSpace(fields[\"name\"]); name != \"\" && name != targetSkillName {\n\t\t\treturn \"\", fmt.Errorf(\n\t\t\t\t\"skill patch frontmatter name %q does not match target skill %q\",\n\t\t\t\tname,\n\t\t\t\ttargetSkillName,\n\t\t\t)\n\t\t}\n\t}\n\treturn strings.TrimSpace(stripLeadingH1(markdownBody)), nil\n}\n\nfunc splitSkillFrontmatter(body string) (frontmatter, markdownBody string) {\n\tnormalized := strings.ReplaceAll(strings.TrimSpace(body), \"\\r\\n\", \"\\n\")\n\tlines := strings.Split(normalized, \"\\n\")\n\tif len(lines) == 0 || strings.TrimSpace(lines[0]) != \"---\" {\n\t\treturn \"\", body\n\t}\n\tend := -1\n\tfor i := 1; i < len(lines); i++ {\n\t\tif strings.TrimSpace(lines[i]) == \"---\" {","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/evolution/apply.go#L210-L246","documentation":"renderDeployablePatchBody (pkg/evolution/apply.go:228) strips frontmatter from append/merge patch bodies; if the patch carries a `name` it must equal the target skill or be omitted entirely. Unlike the full-body check (where name is required and must match), the patch name is optional but must not disagree — a disagreeing patch header means the patch was written for a different skill.","triggerScenarios":"Append/merge draft whose BodyOrPatch frontmatter declares `name: other-skill` while TargetSkillName differs — typically a patch excerpted from another skill's SKILL.md with its frontmatter left in, or an LLM echoing the source skill's name into the patch header.","commonSituations":"Shortcut/merge drafts assembled by copying sections of existing skill files; copy-paste patch authoring; generator prompts that include example frontmatter from a differently-named skill.","solutions":["Remove the `name:` key from the patch frontmatter (it is stripped during rendering anyway)","Or set the patch frontmatter name to exactly draft.TargetSkillName","Regenerate the patch without copying source-skill frontmatter"],"exampleFix":"// before (append patch)\n---\nname: source-skill\ndescription: ...\n---\n## New section\n\n// after\n## New section","handlingStrategy":"validation","validationCode":"func patchNameAgrees(body, target string) error {\n\t// reuse frontmatter extraction; only fail when a name is present AND different\n\tvar fm struct {\n\t\tName string `yaml:\"name\"`\n\t}\n\tif fmBlock := extractFrontmatter(body); fmBlock != \"\" {\n\t\tif err := yaml.Unmarshal([]byte(fmBlock), &fm); err == nil {\n\t\t\tif n := strings.TrimSpace(fm.Name); n != \"\" && n != target {\n\t\t\t\treturn fmt.Errorf(\"patch name %q != target %q\", n, target)\n\t\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := applier.ApplyDraft(ctx, ws, draft); err != nil {\n\tif strings.Contains(err.Error(), \"skill patch frontmatter name\") {\n\t\t// drop or correct the name key in the patch frontmatter\n\t}\n}","preventionTips":["Author append/merge patches as bare markdown sections — no frontmatter at all","When excerpting other skills, strip their frontmatter before reusing the text","A patch frontmatter name is optional; when in doubt omit it"],"tags":["go","skills","frontmatter","patch","validation"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}