- 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.
Requires serenecode package installation. Docstring tags must be at function/class level. Levels 4-6 require --allow-code-execution flag and user consent.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
2 uses
Times used to date
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 1 month ago
- Free with an Agensi account
Requires
Permissions
File Scopes
Shell: runs the serenecode CLI (check, spec, doctor). Read files: SPEC.md, SERENECODE.md, source and tests. Write files: applies fixes the user asked for. Network: only to pip install serenecode from PyPI, and only after the user agrees. Levels 3–6 execute the project's tests and generated inputs; the skill asks before enabling this.