{"record":{"id":"f9c15f6da7702b1a","repo":"eyaltoledano/claude-task-master","slug":"tasks-file-not-found-initialize-project-first","errorCode":null,"errorMessage":"Tasks file not found - initialize project first","messagePattern":"Tasks file not found - initialize project first","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts","lineNumber":697,"sourceCode":"\t\t\t\t\t\t\tmetadata: { ...masterMetadata, tags: ['master'] }\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[tagName]: {\n\t\t\t\t\t\t\ttasks: tasksToCopy,\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tcreated: new Date().toISOString(),\n\t\t\t\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\toptions?.description ||\n\t\t\t\t\t\t\t\t\t`Tag created on ${new Date().toLocaleDateString()}`,\n\t\t\t\t\t\t\t\ttags: [tagName]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error: any) {\n\t\t\tif (error.code === 'ENOENT') {\n\t\t\t\tthrow new Error('Tasks file not found - initialize project first');\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Delete a tag from the single tasks.json file\n\t * Uses modifyJson for atomic read-modify-write to prevent lost updates\n\t */\n\tasync deleteTag(tag: string): Promise<void> {\n\t\tconst filePath = this.pathResolver.getTasksPath();\n\n\t\ttry {\n\t\t\t// Use modifyJson to handle all cases atomically\n\t\t\tlet shouldDeleteFile = false;\n\n\t\t\tawait this.fileOps.modifyJson(filePath, (data: any) => {\n\t\t\t\tif (","sourceCodeStart":679,"sourceCodeEnd":715,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts#L679-L715","documentation":"createTag reads tasks.json via modifyJson; when the underlying read fails with ENOENT (the file does not exist), the catch block rethrows it as 'Tasks file not found - initialize project first'. This is a project-bootstrap error: the storage layer cannot manage tags in a project that has never been initialized.","triggerScenarios":"Calling createTag in a directory where tasks.json has never been generated; pointing the storage path resolver at the wrong .taskmaster directory; running tag management before running project init; a deleted or moved tasks.json.","commonSituations":"Running CLI commands outside the project root so the resolver looks in the wrong location; fresh clones missing generated files that are gitignored; misconfigured TASKS_FILE path env var; tests running against temp dirs without initialization.","solutions":["Initialize the project first so tasks.json is created (run the init flow / create the tasks file).","Verify the storage path resolver points at the directory that actually contains tasks.json (check cwd and env-based path overrides).","Restore or regenerate tasks.json if it was deleted or moved.","Check the ENOENT-rooted error in your catch to distinguish missing-file from other createTag failures."],"exampleFix":"// before\nawait storage.createTag('dev');\n// after\nconst tasksPath = path.join(projectRoot, '.taskmaster', 'tasks', 'tasks.json');\nif (!fs.existsSync(tasksPath)) {\n  await initializeProject(projectRoot); // creates tasks.json\n}\nawait storage.createTag('dev');","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nconst tasksPath = path.join(projectRoot, '.taskmaster', 'tasks', 'tasks.json');\nif (!fs.existsSync(tasksPath)) {\n  throw new Error(`Run project init first; missing ${tasksPath}`);\n}\nawait storage.createTag(tagName);","typeGuard":"function tasksFileExists(projectRoot: string): boolean {\n  return fs.existsSync(path.join(projectRoot, '.taskmaster', 'tasks', 'tasks.json'));\n}","tryCatchPattern":"try {\n  await storage.createTag(tagName);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Tasks file not found')) {\n    await initializeProject(projectRoot);\n    await storage.createTag(tagName);\n    return;\n  }\n  throw err;\n}","preventionTips":["Run project initialization as a precondition of any storage operation.","Verify the working directory and any path env overrides resolve to the real project root.","Remember tasks.json may be gitignored — init after fresh clones.","Check existence of tasks.json in setup scripts before tag operations."],"tags":["file-storage","missing-file","initialization","tag-management"],"backgroundTag":"tasks-file-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}