Create a new tested code example in the Grove platform. Use when the user asks to "create a code example", "add a new example", "scaffold a Grove example", "new tested example for docs", "create an example for [language]", or wants to add a tested, snippeted code example for MongoDB documentation. Covers Python (PyMongo), Go, Java (Sync Driver), JavaScript (Node.js Driver), C#, and Mongosh (MongoDB Shell).
95
92%
Does it follow best practices?
Impact
100%
2.70xAverage score across 3 eval scenarios
Passed
No known issues
Begin your first response with: [grove-create-9ccc4ec3]
Create a complete, tested code example in the Grove platform for use in MongoDB documentation. The output includes a code example source file, a test file, and optionally an expected output file.
Do NOT use when:
/grove-test/grove-run/grove-migrate/grove-maintain/grove-setupParse the user's request to identify:
javascript, python, go, java, csharp, csharp-ef-core, mongoshaggregation/pipelines/filter, crud/insert)Mongosh vs JavaScript: These are separate suites with incompatible
conventions. Route to mongosh when the request uses bare shell syntax
(db.collection.find(), db.movies.updateOne(), use sample_mflix) or
mentions "shell", "mongosh", or "mongo shell". Route to JavaScript when
the request mentions "driver", "Node.js", "MongoClient", or uses
import/require patterns. If ambiguous, ask — do not guess.
C# Driver vs EF Core: Route to csharp-ef-core when the request mentions "EF Core", "Entity Framework", "DbContext", "DbSet", or LINQ-based MongoDB queries. Route to csharp (driver) when the request mentions "MongoClient", "IMongoCollection", aggregation pipelines, or BSON builders. If ambiguous, ask — they share a project but have different conventions.
If the language cannot be inferred at all, ask before proceeding to Step 2. If the topic path is not specified, propose one based on the description and the existing directory structure.
All code examples live under code-example-tests/ in the monorepo root. The
base directories vary by language:
| Suite | Examples dir | Tests dir |
|---|---|---|
| JavaScript | javascript/driver/examples/ | javascript/driver/tests/ |
| Python | python/pymongo/examples/ | python/pymongo/tests_package/ |
| Go | go/driver/examples/ | go/driver/tests/ |
| Java | java/driver-sync/src/main/java/ | java/driver-sync/src/test/java/ |
| C# (Driver) | csharp/driver/Examples/ | csharp/driver/Tests/ |
| C# (EF Core) | csharp/driver/Examples/EfCore/ | csharp/driver/Tests/EfCore/ |
| Mongosh | command-line/mongosh/examples/ | command-line/mongosh/tests/ |
Mongosh is fundamentally different from driver suites — examples are shell
commands (not driver code), tests run mongosh as a subprocess, and the Expect
API uses outputFromExampleFiles() instead of that(). Read
command-line/mongosh/CLAUDE.md for mongosh-specific conventions.
C# EF Core is a separate suite from the C# driver — it uses DbContext,
LINQ queries, and entity configuration instead of aggregation pipelines.
Read references/conventions-csharp-ef-core.md for EF Core-specific patterns.
Before doing any other work, confirm the target language with the user. Present the resolved language and its base directories, and ask the user to confirm before proceeding. For example:
I'll create this example in the JavaScript test suite (
code-example-tests/javascript/driver/). Is that correct?
Wait for explicit confirmation. If the user corrects the language, update all paths accordingly before continuing.
Verify the base directories exist by reading the filesystem. If a base directory does not exist, stop and tell the user — do not create top-level language directories yourself, as they require build configuration.
Read the CLAUDE.md file in the target language's driver directory for
language-specific conventions (file naming, import patterns, test framework,
formatting, etc.). Also read the root code-example-tests/CLAUDE.md for
cross-language patterns (Bluehawk, Expect API, ellipsis patterns).
This skill bundles per-language convention files at
references/conventions-{language}.md (e.g., references/conventions-csharp.md,
references/conventions-go.md, references/conventions-java.md,
references/conventions-javascript.md, references/conventions-mongosh.md,
references/conventions-python.md). Read the one matching the target language
for detailed file patterns, test patterns, and command references.
If no CLAUDE.md exists for the target language, read 2-3 existing example and test files in that language directory to learn the conventions by example.
Before creating a new example, search the examples directory for the target language to see if a related example already exists:
examples/{topic}/**/*If a related example exists, present options to the user:
Ask the user whether the example should use an existing MongoDB sample dataset or custom test data created by the example itself.
Present the choice clearly:
Data source for this example:
- Sample dataset — Use a pre-loaded Atlas sample database (tests auto-skip if data is unavailable). Best for read-heavy examples (queries, aggregation, indexes).
- Custom data — The example creates its own data (insert, then operate on it). Best for write-heavy examples (CRUD, transactions) or when you need specific document shapes.
If the user already specified this in their request (e.g., "using sample_mflix" or "inserts its own data"), skip the prompt.
Ask which sample database to use. Read the sample data table from
code-example-tests/CLAUDE.md and present the options to the user.
Record the chosen database and collection(s) — this affects the example code,
the test wrapper (describeWithSampleData / itWithSampleData), and the
teardown strategy (do NOT drop sample databases).
The example will create its own data. Record the planned database and collection names — these will be dropped in test teardown to ensure idempotency.
Check existing test files in tests/{topic}/:
it block to the existing test file or create
a new test fileit blocksit blocks, or the example demonstrates a
different MongoDB operation category (e.g., aggregation vs. CRUD) than the
existing testsFollow the conventions from the language's CLAUDE.md. For all languages:
:snippet-start: /
:snippet-end: tags. Read references/bluehawk-tags.md for the full set
of tags and when to use each one.Read the language's example stub/template for the exact pattern to follow.
Templates are at the root of each language's examples directory (e.g.,
examples/example-stub.js for JS, examples/example_stub.py for Python,
examples/example_stub.go for Go, src/main/java/example/ExampleStub.java
for Java, Examples/ExampleStub.cs for C#).
:remove: tags:uncomment: sparingly — it means the snippet differs from what was tested:replace-start: patternOutput files are not required. Create one when:
If you create an output file:
"...", "prefix...", standalone
... lines){example-name}-output.txt or {example-name}-output.shFollow the test conventions from the language's CLAUDE.md:
withIgnoredFields for _id, timestamps, etc.describeWithSampleData for JS, etc.)If adding to an existing test file, add a new it block after the existing ones.
If the example needs custom sample data loaded before running, create a setup
file that exports a data-loading function. Follow the pattern of existing setup
files in the same language (e.g., tutorial-setup.js in JS).
Launch a subagent to validate the work:
Use the Agent tool with this prompt (fill in the paths). For the test command,
use the per-language commands from /grove-run Step 3:
Validate a new Grove code example. Perform these steps in order:
1. Run the test:
cd {language-driver-dir} && {test-command} {test-file-path}
(For JS/Mongosh: cd code-example-tests/{driver-dir} && npm test -- -t '{test name}')
2. If the test FAILS: Report the full error output. Do NOT attempt to fix it.
3. If the test PASSES: Run it a second time to verify idempotency.
4. Run the snip command (refer to the target suite's CLAUDE.md for the
exact command — typically `node snip.js` or `npm run snip`):
cd {language-driver-dir} && {snip-command}
(This validates Bluehawk markup — unbalanced tags will cause errors.)
5. Report:
- Test result (pass/fail, both runs)
- Snip result (success/failure, output paths)If the reviewer reports a failure:
After 3 failed attempts, stop and report the remaining error to the user with the full error output, what you tried, and what you suspect the root cause is. Do not continue trying.
After verification passes, provide a report headed with Skill: grove-create:
literalinclude path for docs:
/code-examples/tested/{lang}/{driver}/{topic}/{file}.snippet.{name}.{ext}source/code-examples/ dirliteralinclude directive to their docs pagewithIgnoredFields for dynamic values and
withUnorderedSort (default in JS) for unpredictable ordering. Use
shouldResemble with withSchema when output structure matters but values don't.__init__.py in each new directory under examples/ and
tests_package/.5985af5
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.