langchain-ai/deepagents · error · SystemExit
Error: Could not create project skills directory.
Error message
Error: Could not create project skills directory.
What it means
`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.
Source
Thrown at libs/code/deepagents_code/skills/commands.py:454
raise SystemExit(1)
# Determine target directory
credentials = Credentials.from_environment()
if project:
if not credentials.project_root:
console.print("[bold red]Error:[/bold red] Not in a project directory.")
console.print(
"[dim]Project skills require a .git directory "
"in the project root.[/dim]",
style=theme.MUTED,
)
raise SystemExit(1)
skills_dir = ensure_project_skills_dir(credentials.project_root)
if skills_dir is None:
console.print(
"[bold red]Error:[/bold red] Could not create project skills directory."
)
raise SystemExit(1)
else:
skills_dir = ensure_user_skills_dir(agent)
skill_dir = skills_dir / skill_name
# Validate the resolved path is within skills_dir
is_valid_path, path_error = _validate_skill_path(skill_dir, skills_dir)
if not is_valid_path:
console.print(f"[bold red]Error:[/bold red] {path_error}")
raise SystemExit(1)
if skill_dir.exists():
if output_format == "json":
from deepagents_code.output import write_json
write_json(
"skills create",
{View on GitHub (pinned to a1af029e6e)
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
Example fix
// before (failing shell) dcode skills create my-skill --project # run from $HOME, no project root // after cd ~/work/my-project && dcode skills create my-skill --project
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
import os
def can_create_project_skills_dir(project_root: str) -> bool:
root = Path(project_root)
if not root.is_dir():
return False
probe = root / ".claude"
try:
probe.mkdir(parents=True, exist_ok=True)
return os.access(probe, os.W_OK)
except OSError:
return False
assert can_create_project_skills_dir("."), "project skills dir not creatable" Type guard
def has_writable_project_root(path: str | None) -> bool:
return bool(path) and Path(path).is_dir() and os.access(path, os.W_OK) Prevention
- 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
When it happens
Trigger: 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`.
Common situations: 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.
Related errors
- Error: Failed to fully delete skill: {e} Warning: Some files
- debug log directory is not owned by the current user: {path}
- Cannot determine whether {str(left)!r} is {str(right)!r}: {e
- Invalid DEEPAGENTS_HOME {str(root)!r}: exists but cannot be
- Could not resolve {label} path {raw_path!r}: {exc}. Ensure t
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/49f9820aefeb7c99.
Report an issue: GitHub.