{"record":{"id":"44e5ff00bbc693d8","repo":"langchain-ai/deepagents","slug":"error-not-in-a-project-directory","errorCode":null,"errorMessage":"Error: Not in a project directory.","messagePattern":"Error: Not in a project directory\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"libs/code/deepagents_code/skills/commands.py","lineNumber":448,"sourceCode":"        console.print(\n            \"[dim]Per Agent Skills spec: names must be lowercase alphanumeric \"\n            \"with hyphens only.\\n\"\n            \"Examples: web-research, code-review, data-analysis[/dim]\",\n            style=theme.MUTED,\n        )\n        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():","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/skills/commands.py#L430-L466","documentation":"Raised by the /skills create command when --project is requested but the current environment has no project root (no .git directory at the project root). Project-level skills require a git repo to anchor the skills directory, so the command exits with SystemExit(1).","triggerScenarios":"Running skills create --project outside a git repository, or in a repo whose project root cannot be located by Credentials.from_environment() / project_root is falsy.","commonSituations":"Running the command in a home directory or non-repo folder; being in a subdirectory of a repo where detection fails; invoking in CI from the wrong checkout directory; a repo initialized without .git (worktree/downloaded archive).","solutions":["cd into the git repository root (or a directory inside it) before running the command","Run git init if the directory should be a project","Drop the --project flag to create the skill in the user-level skills directory instead","Verify detection: ensure a .git directory exists at the expected project root"],"exampleFix":"// before\n$ cd ~/scratch && dcode skills create code-review --project\nError: Not in a project directory.\n\n// after\n$ cd ~/my-repo && dcode skills create code-review --project  # has .git","handlingStrategy":"fallback","validationCode":"from pathlib import Path\nif project_flag and not Path.cwd().joinpath(\".git\").exists() and not find_project_root(Path.cwd()):\n    print(\"Not in a project; creating a user-level skill instead.\")\n    project_flag = False","typeGuard":null,"tryCatchPattern":"try:\n    run_skills_create(name=name, project=True)\nexcept SystemExit:\n    run_skills_create(name=name, project=False)  # fall back to user skills dir","preventionTips":["Check for a .git directory before using --project","Run the command from inside the repository you target","Use git init if the folder should be a project","Omit --project to create skills in the user-level directory when outside a repo"],"tags":["skills","cli","git","project"],"backgroundTag":"not-in-project-directory","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}