{"record":{"id":"c155c5c2bab6e81b","repo":"crewAIInc/crewAI","slug":"directory-skill-dir-already-exists","errorCode":null,"errorMessage":"Directory {skill_dir} already exists.","messagePattern":"Directory (.+?) already exists\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/skills/main.py","lineNumber":59,"sourceCode":"\n    def __init__(self) -> None:\n        BaseCommand.__init__(self)\n        PlusAPIMixin.__init__(self, telemetry=self._telemetry)\n\n    def create(self, name: str, in_project: bool = True) -> None:\n        \"\"\"Scaffold a new skill directory.\n\n        If pyproject.toml is present (crew project), creates ./skills/{name}/.\n        Otherwise creates ./{name}/.\n        \"\"\"\n        if in_project and os.path.isfile(\"pyproject.toml\"):\n            skill_dir = Path(\"skills\") / name\n        else:\n            skill_dir = Path(name)\n\n        if skill_dir.exists():\n            console.print(f\"[red]Directory {skill_dir} already exists.[/red]\")\n            raise SystemExit(1)\n\n        skill_dir.mkdir(parents=True)\n        (skill_dir / \"scripts\").mkdir()\n        (skill_dir / \"references\").mkdir()\n        (skill_dir / \"assets\").mkdir()\n\n        skill_md = skill_dir / \"SKILL.md\"\n        skill_md.write_text(_SKILL_MD_TEMPLATE.format(name=name), encoding=\"utf-8\")\n\n        console.print(\n            f\"[green]Created skill [bold]{name}[/bold] at [bold]{skill_dir}[/bold].[/green]\"\n        )\n        console.print(f\"Edit [bold]{skill_md}[/bold] to define the skill instructions.\")\n\n    def install(self, ref: str) -> None:\n        \"\"\"Download and install a registry skill.\n\n        Format: @org/name","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/skills/main.py#L41-L77","documentation":"`crewai skill create <name>` refuses to scaffold when the target skill directory already exists. The CLI computes the destination as `./skills/<name>/` when a `pyproject.toml` is present, otherwise `./<name>/`, and exits with SystemExit(1) before writing anything rather than overwriting an existing skill.","triggerScenarios":"Running `crewai skill create my-skill` twice, or running it once in a project root (creating `skills/my-skill/`) and again from inside the `skills/` directory (creating `skills/my-skill/` again via the bare `./<name>/` path). Any pre-existing file or directory with the same name also triggers it.","commonSituations":"Re-running a scaffold command after a partial earlier run; forgetting the command already succeeded; running from the wrong directory so `in_project` detection differs between attempts; name collision with an unrelated folder.","solutions":["Pick a different skill name: `crewai skill create my-skill-v2`.","If the existing directory is an abandoned scaffold, delete it (`rm -rf skills/my-skill`) and re-run the command.","If you meant to work on the existing skill, `cd` into it instead of re-scaffolding."],"exampleFix":"# before\ncrewai skill create researcher   # second run -> Directory skills/researcher already exists.\n\n# after\nrm -rf skills/researcher && crewai skill create researcher\n# or\ncrewai skill create researcher-2","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\n\ndef skill_target_dir(name: str, in_project: bool) -> Path:\n    return Path(\"skills\") / name if in_project else Path(name)\n\ndef can_scaffold(name: str) -> bool:\n    in_project = os.path.isfile(\"pyproject.toml\")\n    return not skill_target_dir(name, in_project).exists()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `Path('skills') if isfile('pyproject.toml') else Path(name)` for existence before calling `crewai skill create`.","Run create commands from a consistent directory (project root) so the target path is predictable.","Treat an existing directory as a signal to resume work, not to re-scaffold."],"tags":["cli","filesystem","scaffold","skill"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}