crewAIInc/crewAI · error · SystemExit

Directory {skill_dir} already exists.

Error message

Directory {skill_dir} already exists.

What it means

`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.

Source

Thrown at lib/cli/src/crewai_cli/skills/main.py:59

    def __init__(self) -> None:
        BaseCommand.__init__(self)
        PlusAPIMixin.__init__(self, telemetry=self._telemetry)

    def create(self, name: str, in_project: bool = True) -> None:
        """Scaffold a new skill directory.

        If pyproject.toml is present (crew project), creates ./skills/{name}/.
        Otherwise creates ./{name}/.
        """
        if in_project and os.path.isfile("pyproject.toml"):
            skill_dir = Path("skills") / name
        else:
            skill_dir = Path(name)

        if skill_dir.exists():
            console.print(f"[red]Directory {skill_dir} already exists.[/red]")
            raise SystemExit(1)

        skill_dir.mkdir(parents=True)
        (skill_dir / "scripts").mkdir()
        (skill_dir / "references").mkdir()
        (skill_dir / "assets").mkdir()

        skill_md = skill_dir / "SKILL.md"
        skill_md.write_text(_SKILL_MD_TEMPLATE.format(name=name), encoding="utf-8")

        console.print(
            f"[green]Created skill [bold]{name}[/bold] at [bold]{skill_dir}[/bold].[/green]"
        )
        console.print(f"Edit [bold]{skill_md}[/bold] to define the skill instructions.")

    def install(self, ref: str) -> None:
        """Download and install a registry skill.

        Format: @org/name

View on GitHub (pinned to 754d7323be)

Solutions

  1. Pick a different skill name: `crewai skill create my-skill-v2`.
  2. If the existing directory is an abandoned scaffold, delete it (`rm -rf skills/my-skill`) and re-run the command.
  3. If you meant to work on the existing skill, `cd` into it instead of re-scaffolding.

Example fix

# before
crewai skill create researcher   # second run -> Directory skills/researcher already exists.

# after
rm -rf skills/researcher && crewai skill create researcher
# or
crewai skill create researcher-2
Defensive patterns

Strategy: validation

Validate before calling

import os
from pathlib import Path

def skill_target_dir(name: str, in_project: bool) -> Path:
    return Path("skills") / name if in_project else Path(name)

def can_scaffold(name: str) -> bool:
    in_project = os.path.isfile("pyproject.toml")
    return not skill_target_dir(name, in_project).exists()

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/c155c5c2bab6e81b. Report an issue: GitHub.