dspy-reasoning-modules — скилл для Claude Code: обзор и запуск
Скилл dspy-reasoning-modules помогает настроить сложные модули рассуждений в DSPy 3.2.1: RLM, ProgramOfThought, CodeAct и Parallel. Пригодится при обработке длинных контекстов и вычислениях на Python.
MIT ★ 125 обновлён 2026-06-23
npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a claude-codeЧто делает dspy-reasoning-modules
Скилл содержит правила выбора и применения модулей рассуждений для фреймворка DSPy. Он описывает работу с dspy.RLM для изучения объёмных документов через изолированный REPL и рекурсивные вызовы вспомогательных моделей. Для вычислений и запуска Python с кастомными инструментами скилл настраивает модули ProgramOfThought и CodeAct. Параллельная обработка пакетов с контролем ошибок разворачивается через dspy.Parallel.
Для работы модулей с генерацией кода по умолчанию требуется установленный Deno. Встроенный dspy.PythonInterpreter использует Pyodide и блокирует файловую систему, сеть и переменные окружения хоста. Доступ к локальным каталогам или внешним хостам нужно разрешать явно в параметрах интерпретатора. Без Deno в системе модули RLM, ProgramOfThought и CodeAct не запустятся.
Какие задачи решает
- настроить dspy.RLM для анализа объёмных документов без раздувания контекста
- подключить прикладные Python-функции к агенту через dspy.CodeAct
- изолировать выполнение сгенерированного кода в песочнице на базе Deno и Pyodide
- организовать многопоточный запуск задач через dspy.Parallel с отловом сбоев
Примеры запросов агенту
- Собери модуль dspy.RLM для анализа длинного документа с лимитом max_iterations=12
- Настрой dspy.CodeAct с инструментом lookup_rate и проверь права песочницы
- Запусти пачку примеров параллельно в 8 потоков через dspy.Parallel
Как установить dspy-reasoning-modules
1Через Skills CLI (Vercel)
npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a claude-code2Вручную: положить файлы
~/.claude/skills/dspy-reasoning-modules/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/dspy-reasoning-modules/
1Через Skills CLI (Vercel)
npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a codex2Вручную: положить файлы
.agents/skills/dspy-reasoning-modules/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a cursor2Вручную: положить файлы
.cursor/skills/dspy-reasoning-modules/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install OmidZamani/dspy-skills skills/dspy-reasoning-modules2Вручную: положить файлы
.github/skills/dspy-reasoning-modules/SKILL.md1Через Skills CLI (Vercel)
npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a gemini-cli2Командой платформы
gemini skills install https://github.com/OmidZamani/dspy-skills --path skills/dspy-reasoning-modulesВручную: положить файлы
.devin/skills/dspy-reasoning-modules/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о dspy-reasoning-modules
Как установить dspy-reasoning-modules в Claude Code?
Выполните команду npx skills add OmidZamani/dspy-skills --skill dspy-reasoning-modules -a claude-code.
Для чего нужен скилл dspy-reasoning-modules?
Он помогает модели правильно выбирать и конфигурировать модули рассуждений DSPy для работы с большими текстами, кодом и параллельными задачами.
Какие системные зависимости нужны для работы ProgramOfThought и RLM?
По умолчанию требуется установленный Deno. Исполнение кода происходит через Deno и Pyodide с закрытыми правами на сеть и диск.
Исходный текст
SKILL.md · MIT
---
name: dspy-reasoning-modules
version: "1.0.0"
dspy-compatibility: "3.2.1"
tags: ["reasoning"]
requires-extras: []
description: Use for DSPy reasoning modules including RLM, ProgramOfThought, CodeAct, Parallel, sandboxed execution, and long-context workflows.
allowed-tools:
- Read
- Write
- Glob
- Grep
---
# DSPy Reasoning Modules
## Goal
Choose the appropriate DSPy reasoning module for long-context exploration, code-assisted reasoning, or parallel execution.
## Module Selection
| Module | Use it for | Important constraint |
|--------|------------|----------------------|
| `dspy.RLM` | Exploring very large contexts with iterative REPL code and recursive sub-LM calls | Experimental; requires Deno by default |
| `dspy.ProgramOfThought` | Solving tasks by generating and executing Python | Requires Deno by default |
| `dspy.CodeAct` | Combining generated Python with predefined tool functions | Functions only; requires Deno |
| `dspy.Parallel` | Running `(module, example)` pairs concurrently | Tune threads and error handling |
## RLM for Large Contexts
`RLM` treats long inputs as external data in a sandbox rather than placing the full context in each LM prompt.
```python
import dspy
dspy.configure(lm=dspy.LM("openai/gpt-4o"))
rlm = dspy.RLM(
"document, question -> answer",
max_iterations=12,
max_llm_calls=30,
sub_lm=dspy.LM("openai/gpt-4o-mini"),
)
result = rlm(
document=very_long_document,
question="What were the main revenue drivers?",
)
print(result.answer)
```
Use `max_iterations`, `max_llm_calls`, and `max_output_chars` as explicit cost and output bounds.
## Sandboxed Execution
The default `dspy.PythonInterpreter` uses Deno and Pyodide. It denies host filesystem, environment, and network access unless explicitly enabled.
```python
from pathlib import Path
import dspy
with dspy.PythonInterpreter(
enable_read_paths=[Path("./inputs")],
enable_network_access=["api.example.com"],
) as interpreter:
print(interpreter.execute("print('ready')"))
```
Grant only the minimum paths, environment variables, and network hosts needed by the task.
## ProgramOfThought and CodeAct
```python
import dspy
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))
math = dspy.ProgramOfThought("question -> answer")
print(math(question="What is the sum of the first 100 integers?").answer)
```
Use `CodeAct` when generated code also needs curated host-side tools:
```python
def lookup_rate(currency: str) -> float:
"""Return a trusted exchange rate from the application service."""
return rates[currency]
agent = dspy.CodeAct("amount, currency -> converted", tools=[lookup_rate])
```
## Parallel Execution
```python
parallel = dspy.Parallel(num_threads=8, return_failed_examples=True)
results, failed_examples, exceptions = parallel(
[(program, {"question": question}) for question in questions]
)
```
## Best Practices
1. Prefer `Predict` or `ChainOfThought` until code execution or long-context exploration is justified.
2. Treat `RLM` as experimental and load-test before production deployment.
3. Bound loops and sub-LM calls.
4. Keep sandbox permissions narrow.
5. Create separate interpreters for concurrent custom-interpreter use.
## Official Documentation
- **RLM API**: https://dspy.ai/api/modules/RLM/
- **ProgramOfThought API**: https://dspy.ai/api/modules/ProgramOfThought/
- **CodeAct API**: https://dspy.ai/api/modules/CodeAct/
- **Parallel API**: https://dspy.ai/api/modules/Parallel/
© OmidZamani · MIT · OmidZamani/dspy-skills