{"record":{"id":"4dcc061e77c67a99","repo":"siyuan-note/siyuan","slug":"user-skill-is-read-only-s","errorCode":null,"errorMessage":"user skill is read-only: %s","messagePattern":"user skill is read-only: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/skill.go","lineNumber":448,"sourceCode":"\t}\n\tskillDir := filepath.Join(dir, name)\n\tif err := os.MkdirAll(skillDir, 0755); err != nil {\n\t\treturn err\n\t}\n\tskillMdPath := filepath.Join(skillDir, \"SKILL.md\")\n\treturn filelock.WriteFile(skillMdPath, []byte(content))\n}\n\nfunc RemoveSkill(name string) error {\n\tskillManagementLock.Lock()\n\tdefer skillManagementLock.Unlock()\n\tif err := validateSkillName(name); err != nil {\n\t\treturn err\n\t}\n\trecord, ok := findSkillRecord(readSkillRecords(SkillsDir()), name)\n\tif !ok {\n\t\tif _, found := findSkillRecord(readSkillRecords(UserSkillsDir()), name); found {\n\t\t\treturn fmt.Errorf(\"user skill is read-only: %s\", name)\n\t\t}\n\t\treturn fmt.Errorf(\"skill not found: %s\", name)\n\t}\n\tskillDir := filepath.Join(record.Root, record.DirName)\n\treturn os.RemoveAll(skillDir)\n}\n\nfunc RenameSkill(oldName, newName string) error {\n\tskillManagementLock.Lock()\n\tdefer skillManagementLock.Unlock()\n\tif err := validateSkillName(oldName); err != nil {\n\t\treturn err\n\t}\n\tif err := validateSkillName(newName); err != nil {\n\t\treturn err\n\t}\n\tdir := SkillsDir()\n\trecord, ok := findSkillRecord(readSkillRecords(dir), oldName)","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/skill.go#L430-L466","documentation":"RemoveSkill can only delete skills located in SkillsDir(); if the named skill exists only under UserSkillsDir() it is considered read-only and this error is returned instead of deleting it. User skills are managed externally and protected from removal through this API.","triggerScenarios":"Calling RemoveSkill(name) where name is absent from SkillsDir() records but present in UserSkillsDir() records.","commonSituations":"Attempting to delete a built-in or user-provisioned skill through the management API; scripts cleaning up all skills indiscriminately; mistaking user skills for editable ones.","solutions":["Only remove skills that live in SkillsDir()","Check which directory the skill resides in before attempting removal","Manage user skills through their own provisioning mechanism, not RemoveSkill","Skip user skills in bulk-cleanup scripts by checking location first"],"exampleFix":"// before\nerr := RemoveSkill(\"builtin-helper\") // user skill\n// after\nif isUserSkill(\"builtin-helper\") {\n    // manage via user skill provisioning, not RemoveSkill\n} else {\n    err := RemoveSkill(\"builtin-helper\")\n}","handlingStrategy":"validation","validationCode":"const userSkills = readSkillRecords(UserSkillsDir()).map(r => r.name);\nif (userSkills.includes(name)) throw new Error(`'${name}' is a read-only user skill; cannot remove`);","typeGuard":null,"tryCatchPattern":"try {\n  await removeSkill(name);\n} catch (e) {\n  if (String(e.message).startsWith(\"user skill is read-only\")) {\n    // surface to user: manage user skills through provisioning, not removal\n  }\n}","preventionTips":["Check the skill's source directory before attempting removal","Exclude user skills from bulk-delete operations","Document which skills are externally managed"],"tags":["permissions","read-only","skills"],"backgroundTag":"permission-denied","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}