{"record":{"id":"bc574e3d40015b49","repo":"oraios/serena","slug":"user-prompt-yaml-path-already-exists","errorCode":null,"errorMessage":"{user_prompt_yaml_path} already exists.","messagePattern":"(.+?) already exists\\.","errorType":"exception","errorClass":"FileExistsError","httpStatus":null,"severity":"error","filePath":"src/serena/cli.py","lineNumber":1431,"sourceCode":"\n    @staticmethod\n    @click.command(\n        \"create-override\",\n        help=\"Create an override of an internal prompts yaml for customizing Serena's prompts\",\n        context_settings={\"max_content_width\": _MAX_CONTENT_WIDTH},\n    )\n    @click.argument(\"prompt_yaml_name\")\n    def create_override(prompt_yaml_name: str) -> None:\n        \"\"\"\n        :param prompt_yaml_name: The yaml name of the prompt you want to override. Call the `list` command for discovering valid prompt yaml names.\n        :return:\n        \"\"\"\n        # for convenience, we can pass names without .yml\n        if not prompt_yaml_name.endswith(\".yml\"):\n            prompt_yaml_name = prompt_yaml_name + \".yml\"\n        user_prompt_yaml_path = PromptCommands._get_user_prompt_yaml_path(prompt_yaml_name)\n        if os.path.exists(user_prompt_yaml_path):\n            raise FileExistsError(f\"{user_prompt_yaml_path} already exists.\")\n        serena_prompt_yaml_path = os.path.join(PROMPT_TEMPLATES_DIR_INTERNAL, prompt_yaml_name)\n        shutil.copyfile(serena_prompt_yaml_path, user_prompt_yaml_path)\n        _open_in_editor(user_prompt_yaml_path)\n\n    @staticmethod\n    @click.command(\n        \"edit-override\", help=\"Edit an existing prompt override file\", context_settings={\"max_content_width\": _MAX_CONTENT_WIDTH}\n    )\n    @click.argument(\"prompt_yaml_name\")\n    def edit_override(prompt_yaml_name: str) -> None:\n        \"\"\"\n        :param prompt_yaml_name: The yaml name of the prompt override to edit.\n        :return:\n        \"\"\"\n        # for convenience, we can pass names without .yml\n        if not prompt_yaml_name.endswith(\".yml\"):\n            prompt_yaml_name = prompt_yaml_name + \".yml\"\n        user_prompt_yaml_path = PromptCommands._get_user_prompt_yaml_path(prompt_yaml_name)","sourceCodeStart":1413,"sourceCodeEnd":1449,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/serena/cli.py#L1413-L1449","documentation":"`serena prompts create-override` copies an internal prompt template into the user's prompts directory so it can be customized. If a user prompt YAML with the same name already exists, a FileExistsError is raised to avoid silently overwriting customizations.","triggerScenarios":"Calling `serena prompts create-override <name>` (with or without the .yml suffix) when `<user_prompts_dir>/<name>.yml` already exists on disk.","commonSituations":"Running create-override twice for the same prompt; a previous override left behind from an earlier experiment; scripts that re-run setup idempotently without checking.","solutions":["Edit the existing file directly instead of re-running create-override.","Delete or rename the existing override file if you want a fresh copy from the current template.","Use a different prompt name for the new override.","In scripts, check os.path.exists on the target path before invoking, or handle FileExistsError as a no-op."],"exampleFix":"// before\nserena prompts create-override system_prompt  # second run -> FileExistsError\n// after\n# edit ~/.serena/prompts/system_prompt.yml directly, or:\nrm ~/.serena/prompts/system_prompt.yml && serena prompts create-override system_prompt","handlingStrategy":"try-catch","validationCode":"import os\nfrom serena.prompts import PromptCommands  # or locate the user prompts dir\npath = PromptCommands._get_user_prompt_yaml_path('system_prompt')\nexists = os.path.exists(path)\nif exists:\n    print(f'{path} already overridden; edit it directly')","typeGuard":null,"tryCatchPattern":"try:\n    create_override('system_prompt')\nexcept FileExistsError:\n    print('Override already exists; editing existing file instead')","preventionTips":["Make setup scripts idempotent: treat FileExistsError as success.","Edit the existing override file instead of recreating it.","Back up overrides before re-running create-override after a fresh template update."],"tags":["cli","prompts","file-exists"],"backgroundTag":"file-already-exists","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}