agentsclimarketplace

Assignment refactor

Skill AlexGeControl/Neo4J-Graph-Academy-Fundamentals/.claude/skills/assignment-refactor

Turn a NEO4J-GA-FUND topic's GraphAcademy lessons into a CMU/Stanford-style autograded programming assignment: a reference solution (Cypher + Python), a student starter (stubs + docstring/Cypher contracts), and a pytest autograder that grades BEHAVIOR against a local Neo4j running in Docker (seeded Movies graph) using the official neo4j Python driver. Reuses the shared `assignment/_harness/`. Use when the user wants a topic's exercises turned into a real, offline-gradeable assignment. Phase 5 of the courseware pipeline.From its SKILL.md

Install
npx -y skills add AlexGeControl/Neo4J-Graph-Academy-Fundamentals --skill assignment-refactor

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

10.6 KB, as published. Nobody here has run it

assignment-refactor (Neo4j)

Turns "watch me run Cypher in the browser" into "write it yourself, graded" — the way CMU/Stanford assignments are shaped: a hidden reference solution, a student starter with hollowed bodies + contracts, and a pytest suite that boots a real Neo4j in Docker, seeds it, and asserts on observable behavior. Reuses the shared harness in assignment/_harness/ (do not re-implement the grader core or the container plumbing).

Hard constraints (from the repo rules)

  • Offline-gradeable on local Neo4j via Docker. No Aura, no cloud account, no network at grade time. The autograder starts a throwaway Neo4j container, loads seed/movies.cypher, and asserts with pytest using the official neo4j driver. If a design needs a hosted service, redesign it to run locally.
  • For the GraphRAG capstone: the core must be gradeable for free — gate any embedding-API test behind an API key and provide a deterministic local-embedding (e.g. hashing/bag-of-words vectors) or a fixture fallback so the offline core stays green without a paid call.
  • Read, never rewrite, raw/ and reports/. Compiled lesson material and the staleness report are frozen inputs (see reports/modernization.md).

Output layout

Write under assignment/NN-<slug>/ (folder name matches the manifest's assignments[].{number,slug}; NN zero-padded):

assignment/NN-<slug>/
  README.md            # handout (from _harness/README.template.md): Background, Learning goals,
                       #   Project layout, The tasks, How to run the autograder, Neo4j-in-Docker note, Honor code
  pyproject.toml       # from _harness/pyproject.toml.template: neo4j>=5.20, pytest>=8, [dev] testcontainers[neo4j]
  Makefile             # from _harness/Makefile.template: setup/seed/test/test-one/grade/clean
  conftest.py          # 3-line shim that prepends ../_harness to sys.path and `from conftest import *`
  points.json          # test-id -> {points, question_id, is_written:false, is_coding:true, is_extra_credit}
  meta.json            # due_date placeholder + tex_* flags (false-ok for these coding assignments)
  seed/                # OPTIONAL assignment-specific seed; omit to use the shared _harness Movies graph
    movies.cypher
  src/
    submission/        # STUDENT-EDITABLE Cypher/Python with ### START CODE HERE ### / ### END CODE HERE ###
      __init__.py
      queries.py       # (cypher-read/write) functions returning Cypher strings, or running them via a passed session
      ...              # (modeling/import/graphrag) constraints.cypher, load.cypher, refactor.cypher, retrieval.py, ...
    solution/          # REFERENCE solution, same tree. Its PRESENCE toggles hidden-test scoring (graderUtil).
      __init__.py      #   Ship it for the instructor build; withhold it from the student release.
      ...
  tests/
    graderUtil.py      # COPIED from _harness/graderUtil.py (so `from graderUtil import ...` resolves)
    grader.py          # the autograder: GradedTestCase classes, points.json-driven, CourseTestRunner entrypoint
  starter/             # DERIVED student release: same tree, submission bodies -> NotImplementedError + TODO,
                       #   solution/ removed, README.md present (pyproject readme= must resolve here too)
  MODERNIZATION.md     # what changed vs. the source GraphAcademy lessons and why (from reports/modernization.md)

solution.py vs solution/: either form works — graderUtil toggles hidden tests on importlib.util.find_spec('solution'). For multi-file Neo4j submissions prefer the solution/ package mirroring submission/.

The per-assignment-KIND through-line

Each assignment grades behavior through the driver against the seeded graph, never query text. Match the KIND from the manifest:

  • cypher-read (A01, topic 2): student writes MATCH ... read queries. Graded by result-set equality — run the student's query and the reference query against the seeded Movies graph and compare normalized rows (sort, coerce records to comparable tuples/sets). Tests are read-only; the session fixture is enough.
  • cypher-write (A02, topic 3): student writes CREATE / MERGE / SET / DELETE. Graded by post-state assertions — run the mutation, then query the graph and assert node/relationship existence, property values, counts, idempotency (running MERGE twice changes nothing new). Use a fresh sub-graph or clean up so tests don't bleed into each other.
  • modeling (A03, topics 4–6): student implements a target data model via constraints + load + refactor Cypher. Graded by structural assertions — expected labels present, relationship types and directions, node degrees, intermediate nodes created, duplication eliminated, constraints/indexes present (SHOW CONSTRAINTS / db.schema).
  • import (A04, topic 7): student writes LOAD CSV / Data-Importer-equivalent Cypher (provide CSVs under src/submission/data/ or load from a file:///). Graded by node/relationship counts after import + constraint existence (uniqueness constraints created before load). Keep CSVs tiny and deterministic.
  • graphrag (A05, topic 9): student builds a small KG from provided text/CSV, creates a vector or fulltext index, and writes a retrieval function. Graded on retrieving the right nodes for a query. Core uses a deterministic local embedding (or a fulltext index, which needs no embeddings at all) so it grades free; any real-embedding-API path is a separate test gated behind a key.

Procedure

Mirror the reference skill's flow, adapted to Cypher + Neo4j:

  1. Find the through-line. From raw/transcripts/ + raw/code/ for the assignment's topic(s) and course_manifest.json, identify the ONE evolving task the lessons build (e.g. "answer questions about the movie graph", "evolve a naive model into a refactored one"). Pick the most complete lesson code as the basis.
  2. Design the decomposition. Break it into a handful of single-responsibility graded parts, each mapped to a lesson note. Decide the contract for each: for read/write, a Python function the student fills (returns/runs Cypher); for modeling/import, named .cypher artifacts the grader applies in order. Write the part list + point split into points.json BEFORE coding.
  3. Write the reference solution, modernized per reports/modernization.md (current Cypher syntax, Neo4j 5 idioms, no deprecated clauses; e.g. prefer CREATE CONSTRAINT ... FOR ... REQUIRE over legacy syntax). Add docstrings that state each contract. Verify it runs green against the seeded DB.
  4. Write the pytest autograder (tests/grader.py): one GradedTestCase subclass per question; each test_* has a """<id>: <name>""" docstring whose id (before the first colon) is a key in points.json. Use @graded(...) for timeout / is_hidden / is_extra_credit. Mark DB-backed tests @pytest.mark.db and take the session/neo4j_driver fixture. Assert BEHAVIOR (result sets / post-state / structure / counts), not query strings. Use run_with_solution_if_possible to compare against the reference for hidden tests.
  5. Derive the starter from the solution: keep signatures, docstrings, imports, the tests, and the ### START CODE HERE ### / ### END CODE HERE ### markers; replace each body with raise NotImplementedError(...) (Python) or a TODO comment + an empty/obviously-wrong Cypher placeholder (.cypher files), each naming what and why and pointing at the lesson note ([[NN-lesson]]). Remove solution/. The starter must import and collect tests cleanly and fail at the stubs — never error on import.
  6. Write README.md (from _harness/README.template.md) and MODERNIZATION.md (deltas vs. the source GraphAcademy lessons, sourced from reports/modernization.md). Put a README.md in BOTH the assignment root AND starter/ — pyproject.toml declares readme = "README.md", so an editable install from starter/ fails if its README is missing.
  7. Wire the harness: copy _harness/graderUtil.py into tests/; copy and fill the pyproject.toml, Makefile, points.json, meta.json, README.md templates; write the 3-line conftest.py shim.
  8. Verify (boot Neo4j for real):
    • make setup installs cleanly into .venv (deps importable).
    • With solution/ present: make test (or make grade) is green — the reference solution passes every test against the seeded Docker Neo4j.
    • Switch to the starter tree: pytest collects the same tests and they fail at the stubs (NotImplementedError / wrong result), not at import.
    • Confirm DB-backed tests skip cleanly if Docker is stopped (don't error).

Principles

  • Behavior-based + offline-gradeable. Grade observable graph behavior via the driver; a student who satisfies the contract passes regardless of how they wrote the Cypher. Never require a paid API to pass the core tests.
  • Idempotent, isolated tests. The seed is MERGE-based; write/modeling tests must clean up after themselves (or assert deltas) so one test never corrupts the seeded state another depends on. Prefer the session-scoped seeded neo4j_driver plus per-test scratch labels/keys.
  • Pedagogical scaffolding. Each TODO names what and why and links the relevant lesson note ([[NN-lesson]]).
  • Faithful to GraphAcademy intent, modern in mechanics. Record every deviation in MODERNIZATION.md; source the rationale from reports/modernization.md.
  • Reuse the harness. Container start, seeding, fixtures, and the grader core live in assignment/_harness/. Don't fork them per assignment; extend via the templates and the conftest.py shim.
  • Flip manifest flags only when verified. Advance assignments[].status.{designed,solutionWritten,starterDerived,autograderGreen} in course_manifest.json only after the corresponding step actually verifies.

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.