{"record":{"id":"6e95fe0b9c3248c0","repo":"langchain-ai/deepagents","slug":"error-cannot-determine-base-skills-directory-ref","errorCode":null,"errorMessage":"Error: Cannot determine base skills directory. Refusing to delete.","messagePattern":"Error: Cannot determine base skills directory\\. Refusing to delete\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/skills/commands.py","lineNumber":755,"sourceCode":"    if not skill:\n        console.print(f\"[bold red]Error:[/bold red] Skill '{skill_name}' not found.\")\n        console.print(\"\\n[dim]Available skills:[/dim]\", style=theme.MUTED)\n        for s in skills:\n            source_tag = \"[project]\" if s[\"source\"] == \"project\" else \"[user]\"\n            console.print(f\"  - {s['name']} {source_tag}\", style=theme.MUTED)\n        raise SystemExit(1)\n\n    skill_path = Path(skill[\"path\"])\n    skill_dir = skill_path.parent\n\n    # Validate the path is safe to delete\n    base_dir = project_skills_dir if skill[\"source\"] == \"project\" else user_skills_dir\n    if not base_dir:\n        console.print(\n            \"[bold red]Error:[/bold red] Cannot determine base skills directory. \"\n            \"Refusing to delete.\"\n        )\n        raise SystemExit(1)\n    is_valid_path, path_error = _validate_skill_path(skill_dir, base_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 dry_run:\n        if output_format == \"json\":\n            from deepagents_code.output import write_json\n\n            write_json(\n                \"skills delete\",\n                {\n                    \"name\": skill_name,\n                    \"path\": str(skill_dir),\n                    \"dry_run\": True,\n                },\n            )\n            return","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/skills/commands.py#L737-L773","documentation":"A matching skill was found, but its declared `source` does not map to an available base directory (`project_skills_dir` or `user_skills_dir` is None). The command cannot establish a containment root, so it refuses to delete rather than remove a path it cannot verify is inside a skills directory.","triggerScenarios":"`skill[\"source\"] == \"project\"` but `project_skills_dir` is falsy (e.g. the skills dir was deleted between listing and deletion), or source is user-scoped while `user_skills_dir` is unavailable.","commonSituations":"Stale state where the project root/skills dir changed mid-session, `XDG`/home resolution failing for user skills, or custom skill sources not matching either base directory.","solutions":["Re-run the delete from the correct project root so both the skill and its base dir resolve","Check that the user skills directory (e.g. `~/.config/.../skills`) exists and is resolvable","Verify the skill's source tag via `dcode skills list` and use the matching scope flag"],"exampleFix":"// before\ndcode skills delete my-skill --project   # project skills dir no longer exists\n// after\ncd ~/work/my-project && mkdir -p .claude/skills && dcode skills delete my-skill --project","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef base_dir_available(source: str, project_root: str) -> bool:\n    if source == \"project\":\n        return (Path(project_root) / \".claude\" / \"skills\").is_dir()\n    return Path.home().joinpath(\".claude\", \"skills\").is_dir()\n\nassert base_dir_available(\"project\", \".\")","typeGuard":"def resolvable_base(source: str, project_root: str | None) -> bool:\n    if source == \"project\":\n        return bool(project_root) and (Path(project_root) / \".claude\" / \"skills\").is_dir()\n    return (Path.home() / \".claude\" / \"skills\").is_dir()","tryCatchPattern":null,"preventionTips":["Don't mutate project root or skills dirs between list and delete","Ensure user skills dir (XDG/home) resolves and exists","Match the --project flag to the skill's listed source tag"],"tags":["cli","filesystem","safety"],"backgroundTag":"skills-base-dir-unresolved","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}