# discover_skill_dirs

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/plugins/adapters/skills_middleware/discover_skill_dirs)

Return `(skill_dir, subfolders)` pairs found under `source_path`.

Walks the source tree, treating any directory that directly contains a
`SKILL.md` as a skill directory (a recursion leaf, like a plugin walker).
`subfolders` holds the directory names between the source
root and the skill directory, excluding the skill directory's own name.
A directory that cannot be listed adds a message to `errors`.

## Signature

```python
discover_skill_dirs(
    backend: BackendProtocol,
    source_path: str,
    *,
    errors: list[str] | None = None,
) -> list[tuple[str, tuple[str, ...]]]
```

## Returns

`list[tuple[str, tuple[str, ...]]]`

Skill directories paired with their intermediate subfolder segments.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/4bfa52000ef65ac623d8ada0cb67f67cbdd663ea/libs/code/deepagents_code/plugins/adapters/skills_middleware.py#L283)