python-to-dafny-translator

python-to-dafny-translator is a skill for Claude Code, Codex from ArabelaTso/Skills-4-SE. It costs 74 tokens per session (3,400 once invoked), scanned A, original, Apache-2.0.

A code-conversion guide that turns Python programs into Dafny, a programming language designed to prove that code meets stated rules.

In plain words
What is it for?
It is for porting Python functions and data structures to Dafny and adding formal specifications, such as rules about inputs, outputs, and loops.
Why use it?
It helps move from Python's flexible types and features to code that can be checked for correctness, while keeping the original behavior.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It is for porting Python functions and data structures to Dafny and adding formal specifications, such as rules about inputs, outputs, and loops.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/arabelatso/skills-4-se/python-to-dafny-translator
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ArabelaTso/Skills-4-SE --skill python-to-dafny-translator
Clone the repo
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-to-dafny-translator

README.md
[![agentmods](https://agentmods.dev/badge/skills/arabelatso/skills-4-se/python-to-dafny-translator/github.svg)](https://agentmods.dev/skills/arabelatso/skills-4-se/python-to-dafny-translator)
Your own site
<a href="https://agentmods.dev/skills/arabelatso/skills-4-se/python-to-dafny-translator"><img src="https://agentmods.dev/badge/skills/arabelatso/skills-4-se/python-to-dafny-translator/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-to-dafny-translator

Your own site · 80×15
<a href="https://agentmods.dev/skills/arabelatso/skills-4-se/python-to-dafny-translator"><img src="https://agentmods.dev/badge/skills/arabelatso/skills-4-se/python-to-dafny-translator.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,400 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.03400
Opus 5 $0.00037 $0.01700
Sonnet 5 $0.00015 $0.00680
Haiku 4.5 $0.00007 $0.00340

Measured 5d ago against content hash 714a343b96b1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

python-to-dafny-translator scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/python-to-dafny-translator/SKILL.md · 521 lines

How it starts

The opening of the file, as written. The whole thing — 521 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python to Dafny Translator

Overview

Transform Python programs into equivalent Dafny code that preserves the original semantics while adding formal specifications and leveraging Dafny's verification capabilities.

Translation Workflow

Step 1: Analyze Python Code

Understand the Python program structure and semantics:

  1. Identify program components:

    • Functions and their signatures
    • Classes and methods
    • Data structures (lists, dicts, sets)
    • Control flow (loops, conditionals)
    • Variable types (infer from usage)
  2. Understand semantics:

    • What does the program compute?
    • What are the inputs and outputs?
    • What are the preconditions and postconditions?
    • Are there invariants or constraints?
  3. Note translation challenges:

    • Dynamic typing
    • Mutable data structures
    • Exception handling
    • Python-specific features (list comprehensions, generators)

Step 2: Design Dafny Structure

Plan the Dafny equivalent:

  1. Choose appropriate types:

    • int for integers (arbitrary precision)
    • nat for non-negative integers
    • bool for booleans
    • string for strings
    • real for floating-point (when needed)
    • seq<T> for lists
    • set<T> for sets
    • map<K, V> for dictionaries
    • array<T> for mutable arrays
  2. Determine function vs method:

    • Function: Pure computation, no side effects, used in specifications
    • Method: Can have side effects, modify state, perform I/O
  3. Plan specifications:

    • Preconditions (requires)
    • Postconditions (ensures)
    • Loop invariants
    • Frame conditions (modifies, reads)

Step 3: Translate Code

Follow these translation principles:

Functions

Pattern: Pure function

# Python
def add(a, b):
    return a + b
// Dafny
function add(a: int, b: int): int
{
    a + b
}

Pattern: Function with specifications

# Python
def max_value(a, b):
    """Returns the maximum of a and b"""
    return a if a > b else b

Read the full file on GitHub · 521 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 521 lines · 74 tokens per session scan A 714a343b96b1

Subscribe to this mod's changes

python-to-dafny-translator is a skill published in the GitHub repository ArabelaTso/Skills-4-SE (251 stars, last pushed 19d ago), licensed Apache-2.0. It adds 74 tokens to every session and 3,400 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

K-Dense-AI/scientific-agent-skills · 56 tokens

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use…

K-Dense-AI/scientific-agent-skills · 73 tokens

cobrapy

Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.

K-Dense-AI/scientific-agent-skills · 38 tokens

matlab

Build, review, migrate, and safely plan MATLAB or GNU Octave numerical workflows, including arrays, tabular/time data, tests, projects, graphics, MAT files, and explicit Python interoperability.

K-Dense-AI/scientific-agent-skills · 42 tokens

pennylane

Hardware-agnostic quantum ML framework with automatic differentiation. Use when training quantum circuits via gradients, building hybrid quantum-classical models, or needing device portability across IBM/Google/Rigetti/IonQ. Best for variational algorithms (VQE, QAOA), quantum neural networks, and integration with…

K-Dense-AI/scientific-agent-skills · 98 tokens

scientific-visualization

Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.

Microck/ordinary-claude-skills · 45 tokens