davila7/claude-code-templates · warning

Warning: Error loading permissions

Error message

Warning: Error loading permissions

What it means

loadPermissions merges managed/plugin permission settings (from Claude Code settings files) and warns if any part of that merge fails — typically a JSON.parse failure on a settings.json or a structural surprise (wrong types for agents/commands/hooks/mcps arrays). It returns a default empty permissions object on failure, so the dashboard still renders but with no permission data.

Source

Thrown at cli-tool/src/plugin-dashboard.js:386

      // Load plugin permissions
      for (const plugin of this.plugins || []) {
        const pluginPermissions = await this.loadPluginPermissions(plugin);

        permissions.agents.push(...pluginPermissions.agents);
        permissions.commands.push(...pluginPermissions.commands);
        permissions.hooks.push(...pluginPermissions.hooks);
        permissions.mcps.push(...pluginPermissions.mcps);
      }

      // Add user permissions
      permissions.agents.push(...userPermissions.agents);
      permissions.commands.push(...userPermissions.commands);
      permissions.hooks.push(...userPermissions.hooks);
      permissions.mcps.push(...userPermissions.mcps);

      return permissions;
    } catch (error) {
      console.warn(chalk.yellow('Warning: Error loading permissions'), error.message);
      return permissions;
    }
  }

  async loadUserPermissions() {
    const permissions = {
      agents: [],
      commands: [],
      hooks: [],
      mcps: []
    };

    try {
      // Load user-level agents
      const userAgentsDir = path.join(this.claudeDir, 'agents');
      if (await fs.pathExists(userAgentsDir)) {
        const agentFiles = await fs.readdir(userAgentsDir);
        for (const file of agentFiles.filter(f => f.endsWith('.md'))) {

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Validate all settings JSON files: `jq . ~/.claude/settings.json` and any plugin settings files
  2. Fix syntax errors (trailing commas, comments, unquoted keys) or restore from backup/dotfile history
  3. Ensure the `permissions` object contains arrays (agents, commands, hooks, mcps) as expected by the current schema
  4. Re-run the plugin dashboard after fixing to confirm permissions load

Example fix

// before
"permissions": { "commands": "Bash(*)" }
// after
"permissions": { "commands": ["Bash(*)"] }
Defensive patterns

Strategy: validation

Validate before calling

function validSettings(raw) {
  let s;
  try { s = JSON.parse(raw); } catch { return false; }
  const p = s.permissions;
  return !p || (
    ['agents','commands','hooks','mcps'].every(k =>
      p[k] === undefined || Array.isArray(p[k]))
  );
}

Type guard

function isPermissionsShape(p) {
  return p == null || (
    typeof p === 'object' &&
    ['agents','commands','hooks','mcps'].every(k => p[k] === undefined || Array.isArray(p[k]))
  );
}

Try / catch

catch (error) {
  if (error instanceof SyntaxError) console.warn('settings.json is not valid JSON — fix or remove it');
  return defaultPermissions();
}

Prevention

When it happens

Trigger: Calling loadPermissions (via loadPluginData) when ~/.claude/settings.json or a plugin's settings file is invalid JSON, or when its permissions field has an unexpected shape (permissions.agents being an object instead of an array, null fields where arrays are expected).

Common situations: User hand-edited settings.json and broke the JSON; another tool or AI assistant rewrote settings.json malformed; settings migrated between Claude Code versions with a different permissions schema; merge-conflict markers left in the file from a dotfile sync.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/b0de22a24ca722bb. Report an issue: GitHub.