projectsetup
Structure a new F*/Pulse verification project with Makefile and directory layout
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Structure a new F*/Pulse verification project with Makefile and directory layout
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Use the F* MCP server for interactive, incremental typechecking of F* and Pulse code
Verify F* and Pulse code with fstar.exe and interpret errors
Extract verified F*/Pulse code to C via KaRaMeL (.krml intermediate representation)
Systematic workflows for debugging F*/Pulse verification failures
Debug F* queries sent to Z3, diagnosing proof instability and performance issues
Build F*, Pulse, and KaRaMeL from source (fstar2 branch) for use in a verification project
| name | projectsetup |
| description | Structure a new F*/Pulse verification project with Makefile and directory layout |
| tools | Bash, Read, Write, Edit |
This skill is used when:
For building the F*/Pulse/KaRaMeL toolchain itself, see the sourcebuild skill.
This skill assumes the toolchain is already built.
myproject/
โโโ tools/
โ โโโ FStar/ # fstar2 checkout (gitignored)
โโโ src/
โ โโโ spec/ # Pure specifications
โ โ โโโ Types.fst # Abstract types (may use int, nat, Seq, list)
โ โ โโโ Spec.fst # Pure reference implementation
โ โโโ impl/ # Verified implementations
โ โโโ LowTypes.fst # Machine-width types (UInt64.t, etc.)
โ โโโ LowTypes.fsti # Interface: controls extraction
โ โโโ Helpers.fst # inline_for_extraction utilities
โ โโโ Helpers.fsti
โ โโโ Impl.fst # Main implementation (#lang-pulse)
โ โโโ Impl.fsti # Public API for extraction
โโโ test/
โ โโโ Test.Spec.fst # OCaml spec tests
โ โโโ test_impl.c # C tests for extracted code
โโโ snapshot/ # Committed extraction baseline
โ โโโ Output.c
โ โโโ Output.h
โ โโโ Makefile # Standalone build (no F* needed)
โโโ _cache/ # Gitignored: .checked files
โโโ _output/ # Gitignored: .krml files
โโโ _extract/ # Gitignored: generated .c/.h
โโโ setup.sh # Builds toolchain (see sourcebuild skill)
โโโ Makefile
โโโ .gitignore
tools/FStar
_cache/
_output/
_extract/
*.krml
.depend
# Expects FSTAR_HOME to point to a built FStarLang/FStar@fstar2 checkout
FSTAR_HOME ?= tools/FStar
FSTAR_EXE ?= $(FSTAR_HOME)/bin/fstar.exe
KRML_HOME ?= $(FSTAR_HOME)/karamel
KRML_EXE ?= $(KRML_HOME)/krml
CACHE_DIR = _cache
OUTPUT_DIR = _output
EXTRACT_DIR = _extract
# F* flags
# --already_cached: skip re-checking the standard libraries
# --ext optimize_let_vc: faster VC generation
# --ext fly_deps: lightweight dependency analysis
FSTAR_FLAGS = --cache_checked_modules \
--cache_dir $(CACHE_DIR) \
--odir $(OUTPUT_DIR) \
--already_cached Prims,FStar,Pulse.Nolib,Pulse.Lib,Pulse.Class,PulseCore \
--ext optimize_let_vc \
--ext fly_deps \
--include src/spec \
--include src/impl
FSTAR = $(FSTAR_EXE) $(FSTAR_FLAGS)
# Source files
SPEC_FILES = $(wildcard src/spec/*.fst src/spec/*.fsti)
IMPL_FILES = $(wildcard src/impl/*.fst src/impl/*.fsti)
ALL_FILES = $(SPEC_FILES) $(IMPL_FILES)
# โโ Dependency analysis โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
.depend: $(ALL_FILES)
$(FSTAR) --dep full $(ALL_FILES) --output_deps_to $@
include .depend
# โโ Verification โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
$(CACHE_DIR)/%.checked: | $(CACHE_DIR)
$(FSTAR) $<
$(CACHE_DIR) $(OUTPUT_DIR) $(EXTRACT_DIR):
mkdir -p $@
verify: $(ALL_CHECKED_FILES)
# โโ Extraction (adapt for your modules) โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# List the modules to extract to .krml
KRML_MODULES = MyProject.LowTypes MyProject.Helpers MyProject.Impl
KRML_FILES = $(patsubst %,$(OUTPUT_DIR)/%.krml,$(subst .,_,$(KRML_MODULES)))
$(OUTPUT_DIR)/%.krml: verify | $(OUTPUT_DIR)
$(FSTAR) --codegen krml --extract_module $(subst _,.,$*) \
src/impl/$(subst _,.,$*).fst
extract-krml: $(KRML_FILES)
# If your code uses tuples (fst/snd), also extract FStar.Pervasives.Native
STDLIB_KRML = $(OUTPUT_DIR)/FStar_Pervasives_Native.krml
$(STDLIB_KRML): verify | $(OUTPUT_DIR)
$(FSTAR_EXE) --codegen krml --extract_module FStar.Pervasives.Native \
--odir $(OUTPUT_DIR) --cache_dir $(CACHE_DIR) \
--already_cached Prims,FStar \
FStar.Pervasives.Native.fst
extract-c: extract-krml $(STDLIB_KRML) | $(EXTRACT_DIR)
$(KRML_EXE) \
-tmpdir $(EXTRACT_DIR) \
-skip-compilation \
-warn-error -2-9-17 \
-bundle 'MyProject.Impl=MyProject.Impl,MyProject.LowTypes,MyProject.Helpers[rename=Output]' \
-bundle 'FStar.*,Pulse.*,PulseCore.*,Prims,MyProject.Types,MyProject.Spec' \
-no-prefix MyProject.Impl \
$(KRML_FILES) $(STDLIB_KRML)
# โโ Testing โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
test-extracted: extract-c
$(CC) -I$(KRML_HOME)/include -I$(KRML_HOME)/krmllib/dist/minimal \
-I$(EXTRACT_DIR) $(EXTRACT_DIR)/Output.c test/test_impl.c \
-o test/test_impl && test/test_impl
# โโ Snapshot โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
update-snapshot: extract-c
cp $(EXTRACT_DIR)/Output.c snapshot/
cp $(EXTRACT_DIR)/Output.h snapshot/
.PHONY: verify extract-krml extract-c test-extracted update-snapshot
src/spec/ โ Pure specifications using unbounded types (nat, Seq.seq, list,
option). These define "what" the code should do. They are bundled away during C
extraction and produce no C output.
src/impl/ โ Verified implementations using machine-width types (UInt64.t,
SizeT.t, bool). These define "how" and are extracted to C.
Every implementation module that should be visible to other modules (or appear in
the extracted C header) needs an .fsti file. Internal helpers in the .fst without
.fsti declarations become static in extracted C.
For detailed guidance on writing extraction-ready code (machine-width types, ghost/erased
parameters, inline_for_extraction, avoiding polymorphic stdlib), see the
krmlextraction skill.
Extract spec modules to OCaml and test the pure logic before writing Pulse code:
FSTAR_LIB_DIR ?= $(FSTAR_HOME)/out/lib
OCAML_DIR = _ocaml
test-ocaml: verify | $(OCAML_DIR)
$(FSTAR) --codegen OCaml --extract_module MyProject.Types src/spec/Types.fst
$(FSTAR) --codegen OCaml --extract_module MyProject.Spec src/spec/Spec.fst
$(FSTAR) --codegen OCaml --extract_module Test.Spec test/Test.Spec.fst
cd $(OCAML_DIR) && \
OCAMLPATH=$(abspath $(FSTAR_LIB_DIR)):$$OCAMLPATH \
ocamlfind ocamlopt -package fstar.lib -linkpkg \
MyProject_Types.ml MyProject_Spec.ml Test_Spec.ml -o test_spec
$(OCAML_DIR)/test_spec
Keep a committed copy of extracted C for users who don't have F*:
snapshot/
โโโ Output.c # Extracted C source
โโโ Output.h # Public header
โโโ internal/Output.h # Internal header (if generated)
โโโ test_impl.c # Test harness (copied from test/)
โโโ Makefile # Standalone build
โโโ stubs.c # Any needed stubs (e.g., krmlinit)
Snapshot Makefile:
KRML_HOME ?= path/to/karamel
CFLAGS = -I$(KRML_HOME)/include -I$(KRML_HOME)/krmllib/dist/minimal -I. -Iinternal
test: test_impl.c Output.c stubs.c
$(CC) $(CFLAGS) $^ -o test_impl && ./test_impl
Update snapshot with make update-snapshot after any extraction change.
sourcebuild skill for building the F*/Pulse/KaRaMeL toolchainkrmlextraction skill for KaRaMeL bundle syntax and extraction detailsfstarverifier skill for F*/Pulse error interpretation