{"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/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/src/services/domain/ModeManager.ts#L77-L113","documentation":"Thrown by ModeManager.loadModeFile() after the mode id passes the regex but no <modeId>.json file exists in any of the searched mode directories (CLAUDE_MEM_MODES_DIR, dataDir/modes, packageRoot/modes, packageRoot/../plugin/modes). The message lists every directory searched so the user can see where it looked.","triggerScenarios":"Calling loadMode('my-custom') when modes/my-custom.json does not exist in any modeDir; mode file was deleted during a plugin upgrade; CLAUDE_MEM_MODES_DIR points at the wrong folder.","commonSituations":"User-created mode lived in dataDir/modes which got wiped on reinstall; mode id is correct but file extension is wrong; modes directory never got copied into the package; dev path differs from installed path so plugin/modes is empty.","solutions":["Create the missing <modeId>.json in one of the listed directories (dataDir/modes for user modes is durable across upgrades).","Fix CLAUDE_MEM_MODES_DIR to point at the directory that actually contains your modes.","If the mode was removed intentionally, switch to a mode that exists (the fallback chain tries 'code' next)."],"exampleFix":"// before — modes/research.json does not exist anywhere in modeDirs\nmanager.loadMode('research');\n// throws 'Mode file not found: research.json (searched: /a/modes, /b/modes, ...)'\n\n// after — create the file\n// <dataDir>/modes/research.json\n{ \"name\": \"Research\", \"observation_types\": [...], \"observation_concepts\": [...] }","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nconst candidate = modeDirs.map(d => join(d, `${modeId}.json`)).find(existsSync);\nif (!candidate) {\n  throw new Error(`No mode file for ${modeId}; searched: ${modeDirs.join(', ')}`);\n}","typeGuard":"function modeFileExists(modeId: string, modeDirs: string[]): boolean {\n  return modeDirs.some(d => existsSync(join(d, `${modeId}.json`)));\n}","tryCatchPattern":null,"preventionTips":["Place user modes in dataDir/modes so they survive plugin upgrades.","Confirm CLAUDE_MEM_MODES_DIR points at the real modes folder before relying on it.","After upgrades, verify the bundled modes/ directory (especially code.json) shipped correctly."],"tags":["modes","filesystem","config"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}