ks-cookbook / rules
Cursor rule9 starsChanged 7 months agoMITView on GitHub
How to author a recipe in ks-cookbook
- Reads credentials
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/flagship_author.mdcCursor rule
- .cursor/rules/python_clean_code.mdcCursor rule
The file
We split this recipe_author.mdc into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Mandatory grounding: Every recipe calls at least one MCP tool via recipes/_shared/mcp_client.ks_mcp_session().
- Very specific: line 35
Use the shared wrapper, not hand-rolled MCPServerStdio:
- Distinctive: line 51
No unit tests required. The bar is:
- Very specific: line 57
If the recipe is complex enough to warrant more, add recipes/<name>/test_smoke.py that mocks ks_mcp_session with canned responses and …
- Very specific: line 61
Add your recipe as a one-line row in recipes/INDEX.md.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: How to author a recipe in ks-cookbook
alwaysApply: false
---
# Recipe author rule
Applies when you're adding or editing anything under `recipes/<name>/`.
## Hard constraints (CI-enforced)
1. **≤100 LOC** in `recipe.py` (docstrings + comments don't count). Bigger → flagship.
2. **Mandatory grounding.** Every recipe calls at least one MCP tool via `recipes/_shared/mcp_client.ks_mcp_session()`.
3. **KS-only MCP contract.** Connect only to `knowledgestack-mcp`. Don't add a second MCP server.
4. **Visible citations.** Inline `[chunk:<uuid>]` tags from `read` output, or an explicit `citations` field in structured output.
5. **Defaults must just work.** `uv run python recipes/<name>/recipe.py` (no flags) runs against the seeded sample policies folder (`ab926019-ac7a-579f-bfda-6c52a13c5f41`) and completes.
6. **No secrets in source.** Keys come from `.env` only.
## Frontmatter
First docstring of `recipe.py`:
```python
"""<Title>.
Pain point: <who feels this and why in one sentence>
Framework: <pydantic-ai | LangGraph | raw-openai | raw-anthropic | mcp-only | LlamaIndex | CrewAI>
Tools used: list_contents, read, search_knowledge, ...
Output: <stdout | file | workbook>
"""
```
## Connecting to MCP
Use the shared wrapper, not hand-rolled `MCPServerStdio`:
```python
from recipes._shared.mcp_client import ks_mcp_session
async with ks_mcp_session() as session:
listing = await session.call_tool("list_contents", {"folder_id": folder_id})
passage = await session.call_tool("read", {"path_part_id": path_part_id})
```
## Framework variety
Recipes ship across different frameworks on purpose. If we already have two pydantic-ai recipes, your next contribution should probably be in LangGraph, CrewAI, raw OpenAI function-calling, raw Anthropic tool-use, or MCP-only — whichever reduces duplication.
## Smoke test
No unit tests required. The bar is:
```bash
uv run python recipes/<name>/recipe.py --help # must exit 0
```
If the recipe is complex enough to warrant more, add `recipes/<name>/test_smoke.py` that mocks `ks_mcp_session` with canned responses and asserts the output shape. See `flagships/compliance_questionnaire/` for the pattern.
## INDEX.md
Add your recipe as a one-line row in [`recipes/INDEX.md`](../../recipes/INDEX.md). Keep it terse — title, framework, one-line description, link.
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.

