agentleFS
knowledgestackknowledgestack/ks-cookbook/.cursor/rules/recipe_author.mdc

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.

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
  1. Very specific:

    Mandatory grounding: Every recipe calls at least one MCP tool via recipes/_shared/mcp_client.ks_mcp_session().

    line 13
  2. Very specific:

    Use the shared wrapper, not hand-rolled MCPServerStdio:

    line 35
  3. Distinctive:

    No unit tests required. The bar is:

    line 51
  4. Very specific:

    If the recipe is complex enough to warrant more, add recipes/<name>/test_smoke.py that mocks ks_mcp_session with canned responses and …

    line 57
  5. Very specific:

    Add your recipe as a one-line row in recipes/INDEX.md.

    line 61

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
recipe_author.mdc
---
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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.