{"record":{"id":"49f9820aefeb7c99","repo":"langchain-ai/deepagents","slug":"error-could-not-create-project-skills-directory","errorCode":null,"errorMessage":"Error: Could not create project skills directory.","messagePattern":"Error: Could not create project skills directory\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/skills/commands.py","lineNumber":454,"sourceCode":"        raise SystemExit(1)\n\n    # Determine target directory\n    credentials = Credentials.from_environment()\n    if project:\n        if not credentials.project_root:\n            console.print(\"[bold red]Error:[/bold red] Not in a project directory.\")\n            console.print(\n                \"[dim]Project skills require a .git directory \"\n                \"in the project root.[/dim]\",\n                style=theme.MUTED,\n            )\n            raise SystemExit(1)\n        skills_dir = ensure_project_skills_dir(credentials.project_root)\n        if skills_dir is None:\n            console.print(\n                \"[bold red]Error:[/bold red] Could not create project skills directory.\"\n            )\n            raise SystemExit(1)\n    else:\n        skills_dir = ensure_user_skills_dir(agent)\n\n    skill_dir = skills_dir / skill_name\n\n    # Validate the resolved path is within skills_dir\n    is_valid_path, path_error = _validate_skill_path(skill_dir, skills_dir)\n    if not is_valid_path:\n        console.print(f\"[bold red]Error:[/bold red] {path_error}\")\n        raise SystemExit(1)\n\n    if skill_dir.exists():\n        if output_format == \"json\":\n            from deepagents_code.output import write_json\n\n            write_json(\n                \"skills create\",\n                {","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/skills/commands.py#L436-L472","documentation":"`dcode skills create` failed to create the project-level `.claude/skills` (or equivalent) directory before writing the new skill. `ensure_project_skills_dir` returned None because it could not create or resolve the directory under `credentials.project_root`. The command prints this message and exits with status 1.","triggerScenarios":"Running `skills create` with a project scope when `ensure_project_skills_dir(credentials.project_root)` returns None — the project root lacks a writable location for skills, the target path is occupied by a non-directory file, or filesystem permission errors block `mkdir`.","commonSituations":"Running the command in a read-only checkout, a project root that was mis-detected (e.g. run from `$HOME` or a temp dir), or a path collision where a file named `skills` already exists in the config directory.","solutions":["Verify you are inside a real project (git repo with a writable root) before running `dcode skills create`","Check that no file conflicts with the skills directory path and that the parent directory is writable (`ls -la`, `touch` test)","Fall back to the user scope: `dcode skills create <name> --agent <agent>` without `--project`","Create the skills directory manually if permissions allow, then re-run the command"],"exampleFix":"// before (failing shell)\ndcode skills create my-skill --project   # run from $HOME, no project root\n// after\ncd ~/work/my-project && dcode skills create my-skill --project","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport os\n\ndef can_create_project_skills_dir(project_root: str) -> bool:\n    root = Path(project_root)\n    if not root.is_dir():\n        return False\n    probe = root / \".claude\"\n    try:\n        probe.mkdir(parents=True, exist_ok=True)\n        return os.access(probe, os.W_OK)\n    except OSError:\n        return False\n\nassert can_create_project_skills_dir(\".\"), \"project skills dir not creatable\"","typeGuard":"def has_writable_project_root(path: str | None) -> bool:\n    return bool(path) and Path(path).is_dir() and os.access(path, os.W_OK)","tryCatchPattern":null,"preventionTips":["Always run skills commands from a real project root","Confirm the root is writable before scoped operations","Watch for files colliding with the skills directory name"],"tags":["cli","filesystem","permissions"],"backgroundTag":"skills-directory-creation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}