- Home
- Skills
- Code Quality & Review
- SereneCode: Spec, Type & Contract Verification
Works with the AI Agents you already use
SereneCode: Spec, Type & Contract Verification
Check AI-written Python against your spec, mypy types, and icontract contracts, then fix findings level by level.
Free
SereneCode: Spec, Type & Contract Verification
Example session with this skill installed
Check my new UserProfile class against REQ-001 with serenecode and fix whatever it finds, up to level 3.
- Read your context and instructions
- Compiled the serenecode
Verified UserProfile against SPEC.md up to Level 3. Final verdict:
complete. Getting there took three passes, and the type check found a real bug.
Pass 1: Level 1 (structural) failed
| Finding | Fix |
|---|---|
SPEC.md has no **Source:** line | Added **Source:** none — this SPEC.md is authoritative. |
__init__ missing precondition, postcondition and docstring | Added @require("@" in email), an @ensure that the stored email is normalised, and a docstring |
update_email missing postcondition | Added @ensure: the result equals the stored email and is already normalised |
Pass 2: Level 2 (mypy --strict) failed
[FAIL] user.py line 34
Incompatible types in assignment (expression has type "str | None",
variable has type "str") [assignment]
This was more than an annotation problem. update_email stored the
raw address and only normalised the value it returned, so after update_email(" New@Example.COM ") the
profile held " New@Example.COM ". That violates REQ-001.
def update_email(self, new_email: str) -> str:
"""Store a normalised email address and return it."""
self.email = new_email.strip().lower()
return self.email
Pass 3: Level 3 (tests and coverage) passed
Serenecode Check — PASSED (verdict: complete)
11 checked, 8 passed, 0 failed, 0 skipped, 3 exempt (2 advisory)
REQ-001: implemented (Implements:onUserProfile) and tested (Verifies:ontest_update_email_normalises)__init__andupdate_email: 100% line and branch coverage
Still open: 2 dead-code advisories say UserProfile and update_email look unused, because nothing under src/ calls them yet. Do you want me to allowlist them with # allow-unused: <reason>, or leave them until callers exist?
Note: Level 3 means the tests passed and the coverage threshold was met. It doesn't prove the code correct.
Connects securely to your tools. The creator never sees your data.
About this skill
SereneCode turns "did the agent ship code?" into "does it match the spec, the types, and the contracts we agreed on?"
This skill teaches your agent to drive the open-source SereneCode verifier (MIT, on PyPI) while it writes Python:
- Spec first. Requirements live in
SPEC.mdasREQ-xxxIDs. Functions are taggedImplements:and tests are taggedVerifies:, so every requirement can be traced to code and tests. - Enforceable contracts. Preconditions, postconditions, and class invariants with icontract. The agent writes real conditions, not tautologies.
- Verification in the edit loop. The agent checks each change through the SereneCode MCP tools or the CLI, at six levels:
- L1 structure
- L2 mypy
--strict - L3 tests and coverage
- L4 Hypothesis property testing
- L5 CrossHair symbolic execution
- L6 architecture
- Fixes by level. Each finding gives a file, line, and suggestion, and the agent fixes it and reruns the check until the verdict is complete.
- Honest reporting. The agent reports the overall verdict, skipped checks, and exemptions. It never claims that a passing property test proves the code correct.
Requirements: Python and the serenecode package (pip install 'serenecode[mcp]'). The skill asks before it installs anything, and asks before enabling code execution for
levels 3–6. The checks come from the package; this skill is the workflow.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
1 install
Downloaded by developers to date
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 4 days ago
- Free to download with an account
Requires