siyuan-note/siyuan · error

user skill is read-only

Error message

user skill is read-only: %s

What it means

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.

Solutions

  1. Only remove skills that live in SkillsDir()
  2. Check which directory the skill resides in before attempting removal
  3. Manage user skills through their own provisioning mechanism, not RemoveSkill
  4. Skip user skills in bulk-cleanup scripts by checking location first

Example fix

// before
err := RemoveSkill("builtin-helper") // user skill
// after
if isUserSkill("builtin-helper") {
    // manage via user skill provisioning, not RemoveSkill
} else {
    err := RemoveSkill("builtin-helper")
}
Defensive patterns

Strategy: validation

Validate before calling

const userSkills = readSkillRecords(UserSkillsDir()).map(r => r.name);
if (userSkills.includes(name)) throw new Error(`'${name}' is a read-only user skill; cannot remove`);

Try / catch

try {
  await removeSkill(name);
} catch (e) {
  if (String(e.message).startsWith("user skill is read-only")) {
    // surface to user: manage user skills through provisioning, not removal
  }
}

Prevention

When it happens

Trigger: Calling RemoveSkill(name) where name is absent from SkillsDir() records but present in UserSkillsDir() records.

Common situations: 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.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/4dcc061e77c67a99. Report an issue: GitHub.

Appendix: source

Thrown at kernel/util/skill.go:448

	}
	skillDir := filepath.Join(dir, name)
	if err := os.MkdirAll(skillDir, 0755); err != nil {
		return err
	}
	skillMdPath := filepath.Join(skillDir, "SKILL.md")
	return filelock.WriteFile(skillMdPath, []byte(content))
}

func RemoveSkill(name string) error {
	skillManagementLock.Lock()
	defer skillManagementLock.Unlock()
	if err := validateSkillName(name); err != nil {
		return err
	}
	record, ok := findSkillRecord(readSkillRecords(SkillsDir()), name)
	if !ok {
		if _, found := findSkillRecord(readSkillRecords(UserSkillsDir()), name); found {
			return fmt.Errorf("user skill is read-only: %s", name)
		}
		return fmt.Errorf("skill not found: %s", name)
	}
	skillDir := filepath.Join(record.Root, record.DirName)
	return os.RemoveAll(skillDir)
}

func RenameSkill(oldName, newName string) error {
	skillManagementLock.Lock()
	defer skillManagementLock.Unlock()
	if err := validateSkillName(oldName); err != nil {
		return err
	}
	if err := validateSkillName(newName); err != nil {
		return err
	}
	dir := SkillsDir()
	record, ok := findSkillRecord(readSkillRecords(dir), oldName)

View on GitHub (pinned to 9f775e8a12)