async-discipline
Skill6 starsChanged 4 months agoMITView on GitHub
Async-дисциплина проекта: весь I/O через await, никаких requests/time.sleep, синхронные либы через asyncio.to_thread, общие клиенты.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/agents.mdcCursor rule
- architecture-disciplineSkill
- automation-disciplineSkill
- debugging-disciplineSkill
- documentation-disciplineSkill
- error-handling-disciplineSkill
- git-disciplineSkill
- prompt-injection-defenseSkill
- pr-review-disciplineSkill
- pull-request-disciplineSkill
- skill-authoringSkill
- testing-disciplineSkill
The file
Files
Skill: async-discipline
Правила работы с асинхронностью. Источник истины — _docs/instructions.md §4.
Когда использовать
- Пишешь handler, tool, сервис или агентный цикл, где есть I/O (HTTP, файлы, Telegram API,
sqlite-vec, Ollama). - Интегрируешь синхронную библиотеку (
sqlite3,ddgs). - Создаёшь клиент внешнего сервиса.
Алгоритм
- Любой I/O — только через
await. В hot path не должно быть блокирующих вызовов. - Не используй
requests,time.sleep, блокирующие SDK. Разрешено:httpx.AsyncClient,ollama.AsyncClient,aiofiles(если нужно). - Синхронную библиотеку оборачивай в
asyncio.to_thread(...)(например,sqlite3,ddgs). - Не создавай новый event loop внутри handlers/tools — всё работает в loop'е, запущенном aiogram.
- Общие клиенты (HTTP, Ollama, SQLite-соединение) создавай один раз на приложение и закрывай при shutdown. В
__init__tool'а — никаких сетевых вызовов, только сохранение зависимостей. - Метод
runу tool — всегдаasync, даже если работа синхронная (единый контракт).
Пример
Синхронный поиск через ddgs внутри async-tool:
results = await asyncio.to_thread(lambda: DDGS().text(query, max_results=top_k))Чего избегать
requests.get(...),time.sleep(...),open(...).read()в hot path event loop'а.asyncio.run(...)/new_event_loop()внутри handlers и tools.- Создания нового HTTP/Ollama-клиента на каждый запрос вместо переиспользования общего.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

