{"record":{"id":"6ef5497d2c3df4b2","repo":"thedotmack/claude-mem","slug":"mode-file-not-found-modeid-json-searched-t","errorCode":null,"errorMessage":"Mode file not found: ${modeId}.json (searched: ${this.modeDirs.join(', ')})","messagePattern":"Mode file not found: (.+?)\\.json \\(searched: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/services/domain/ModeManager.ts","lineNumber":95,"sourceCode":"      } else {\n        result[key] = overrideValue as T[Extract<keyof T, string>];\n      }\n    }\n\n    return result;\n  }\n\n  private loadModeFile(modeId: string): ModeConfig {\n    if (!MODE_ID_PATTERN.test(modeId)) {\n      throw new Error(`Invalid mode ID: ${modeId}`);\n    }\n\n    const modePath = this.modeDirs\n      .map(modesDir => join(modesDir, `${modeId}.json`))\n      .find(candidate => existsSync(candidate));\n\n    if (!modePath) {\n      throw new Error(`Mode file not found: ${modeId}.json (searched: ${this.modeDirs.join(', ')})`);\n    }\n\n    const jsonContent = readFileSync(modePath, 'utf-8');\n    return JSON.parse(jsonContent) as ModeConfig;\n  }\n\n  loadMode(modeId: string): ModeConfig {\n    const inheritance = this.parseInheritance(modeId);\n\n    if (!inheritance.hasParent) {\n      try {\n        const mode = this.loadModeFile(modeId);\n        this.activeMode = mode;\n        this.activeModeId = modeId;\n        logger.debug('SYSTEM', `Loaded mode: ${mode.name} (${modeId})`, undefined, {\n          types: mode.observation_types.map(t => t.id),\n          concepts: mode.observation_concepts.map(c => c.id)\n        });","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/domain/ModeManager.ts#L77-L113","documentation":"loadModeFile searches each configured mode directory for `<modeId>.json`; if the ID is valid but no candidate file exists on disk, it throws this error listing all searched directories. It means the mode is recognized syntactically but no definition file is installed.","triggerScenarios":"loadMode('xyz') where no modesDir contains xyz.json; modes directory misconfigured/pointing at the wrong path; mode file deleted or never created.","commonSituations":"Custom mode file placed in the wrong directory; typo in the mode name vs the JSON filename; a plugin/version update moved the modes directory; running from a checkout that lacks the built mode assets.","solutions":["Create `<modeId>.json` in one of the listed modeDirs (the error message names them).","Fix the mode name to match an existing file's name (case-sensitive).","Verify modeDirs configuration points at the directory that actually holds your mode files.","Reinstall/rebuild the package so default mode files (e.g. code.json) are present."],"exampleFix":"// before\nawait modeManager.loadMode('architect'); // no architect.json anywhere\n// after\n// write ~/.claude-mem/modes/architect.json with a ModeConfig, then:\nawait modeManager.loadMode('architect');","handlingStrategy":"fallback","validationCode":"const dirs = ['/path/to/modes']; // mirror modeDirs config\nif (!dirs.some(d => fs.existsSync(path.join(d, `${modeId}.json`)))) throw new Error(`No ${modeId}.json in ${dirs.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try { return await manager.loadMode(modeId); } catch (e) { if (e.message.startsWith('Mode file not found')) { logger.warn(`Mode '${modeId}' not installed; using 'code'`); return manager.loadMode('code'); } throw e; }","preventionTips":["Verify the modes directory is created and populated during install/build.","Name mode files exactly `<modeId>.json`, case-sensitive.","Ship default mode files with the package and exclude them from cleanup.","List available mode files at startup to surface missing definitions early."],"tags":["mode-manager","file-not-found","configuration"],"backgroundTag":"file-not-found","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}