csml-rpi/ai-cfd-scientist/cfd-foamagent
Claude Code and agent skill by csml-rpi/ai-cfd-scientist
- community
Checking that the SKILL.md file is still in the repository.
Generate one OpenFOAM case from a natural-language requirement using a markdown-driven FoamAgent loop. Self-contained — embeds parser/planner/writer/reviewer prompts verbatim from Foam-Agent/src/services/. The agent runtime drives the loop natively via Read/Write/Bash. FAISS RAG retrieval uses scripts/rag_query.py; pdflatex, xvfb-run, inline Python, jq, and all other tools are also available — the only forbidden script across the entire system is scripts/orchestrator_run.py.
Install
npx vskill@latest install csml-rpi/ai-cfd-scientist/cfd-foamagentSKILL.md
cfd-foamagent
Skill-mode replacement for the scripts/foam_run.py wrapper. The agent walks through FoamAgent's planner→write→Allrun→run→review loop natively — no Python supervisor, no LangGraph DAG, no nodes/-stage machinery.
The single Python touchpoint is FAISS retrieval. RAG over the OpenFOAM tutorial corpus is the one part of FoamAgent that genuinely needs an embedding model + index lookup; everything else is the agent runtime applying the prompts below to its own Read/Write/Bash tools.
When to use vs other modes
| Path | Use when | |
|---|---|---|
cfd-experiment sweep mode | You have a working baseline + want to vary parameters (typical for code-mod sweeps, sensitivity studies). No FoamAgent needed. | |
| This skill (cfd-foamagent) | Fresh case generation from a natural-language requirement. The first case of a new physics group. Cases that genuinely need RAG-retrieval to ground writer/reviewer in similar tutorials. | |
LangGraph mode (scripts/foam_run.py) | Unattended long runs; the existing Python pipeline. Skill mode is a peer, not a replacement. |
Inputs
case_dir(required) — where the case will be created (always inside<out-dir>/)user_requirement(required) — natural-language description ("simulate flow over a backward-facing step at Re=5100 using simpleFoam with kOmegaSST")mesh_type(optional) —standard_mesh(default, blockMesh-based),custom_mesh(user supplies polyMesh),gmsh(.geo file),copied_case(case copied from baseline, mesh already on disk)
Starter directory is READ-ONLY (perskills/cfd-orchestrator/SKILL.mdnon-negotiable constraints). Whenmesh_type=custom_meshormesh_type=copied_caseand the source is a starter case, copy the case into<case_dir>/first viacp -r, then edit the copy. Neversed -i,> file, or otherwise mutate any path under the starter directory.
max_loop(optional, default 10) — review-rewrite-rerun capcase_stats(optional) —{case_domain: [...], case_category: [...], case_solver: [...]}. If not supplied, the agent infers from the FoamAgent FAISS corpus or fromFoam-Agent/database/raw/openfoam_case_stats.jsonif it exists.
Outputs
<case_dir>/— full OpenFOAM case (mesh, fields, logs, postProcessing)<case_dir>/run_result.json:
- Optional sidecar:
<case_dir>/.foamagent_state.jsoncapturing per-loop summary.
Loop overview
The agent is the LLM, so each "apply X_PROMPT" step means: the agent acts under the system-prompt constraints below as it produces the artifact. The prompts are the agent's mental model for that step.
Stage 1 — Parse the requirement
System prompt (verbatim from Foam-Agent/src/services/plan.py: parse_system_prompt)
User prompt
Output schema
Persist as <case_dir>/.foamagent_state.json#case_info.
Stage 2 — RAG retrieval (FAISS via scripts/rag_query.py)
Query three FAISS indices against the parsed case_info + user_requirement:
If FAISS indices don't exist (scripts/rag_query.py returns rc=2), build them first:
If RAG retrieval fails (rc=3, e.g. embedding model missing), the agent can fall back to:
- Reading a tutorial directly from
$WM_PROJECT_DIR/tutorials/<solver>/<case>/(find one byfind $WM_PROJECT_DIR/tutorials/<solver> -maxdepth 2 -type d | head -5). - Quality is lower but the writer still works; flag
rag_fallback: trueinrun_result.json.
Stage 3 — Decompose into subtasks
System prompt (verbatim from Foam-Agent/src/services/plan.py: decompose_system_prompt)
User prompt
Where:
{dir_structure}— the top hit fromopenfoam_tutorials_structure(read from.foamagent_state.dir.json){dir_counts_str}— small summary like0/ has 4 files, constant/ has 6 files, system/ has 5 files
Output
List of {file_name, folder_name} pairs covering: the boundary fields under 0/, the physical/numerical settings under constant/ and system/, and any custom mesh/scheme overrides.
Persist as <case_dir>/.foamagent_state.json#subtasks.
Stage 4 — Mesh routing
Decide based on mesh_type:
mesh_type | Action | |
|---|---|---|
standard_mesh (default) | Include a system/blockMeshDict subtask. Allrun will run blockMesh. | |
custom_mesh | User supplied <case_dir>/constant/polyMesh/. Skip blockMeshDict. Allrun should run only the solver (and optionally checkMesh). | |
gmsh | User supplied <case_dir>/<case>.geo or <case>.msh. Allrun must run gmshToFoam first. For .geo → .msh conversion, see Foam-Agent/src/services/mesh.py (the GMSH_PYTHON_SYSTEM_PROMPT and the gmshToFoam invocation; agent reads that file directly via Read tool). | |
copied_case | The case was copied from a baseline; constant/polyMesh/ already exists. Skip all mesh-generation subtasks. Reviewer must NOT propose remeshing. |
For gmsh mesh, also apply BOUNDARY_EXTRACTION_SYSTEM_PROMPT (in mesh.py) to extract boundary names from the Gmsh output for 0/<field> boundary blocks.
Stage 5 — Write each subtask file
For each (file_name, folder_name) in subtasks, apply the writer prompt below.
System prompt (verbatim from Foam-Agent/src/services/input_writer.py: INITIAL_WRITE_SYSTEM_PROMPT)
User prompt template
Where:
{tutorial_reference}— concatenation of top-3 hits fromopenfoam_tutorials_details(each tagged<similar_case_N>...</similar_case_N>){written_files_ctx}— list of files the agent has already written in this case, with their content (gives the writer cross-file consistency context)
Iteration order
Write files in this order so each step has the prior context it needs:
system/controlDict(sets the application name everything else aligns to)system/fvSchemes,system/fvSolutionconstant/transportProperties(orconstant/physicalProperties,constant/cloudProperties, etc., depending on solver)constant/momentumTransport(for RANS) orconstant/turbulenceProperties(legacy naming)system/blockMeshDict(ifmesh_type=standard_mesh)0/<field>files (one per field declared incontrolDict/transportProperties/turbulence model)- Any extra subtasks not covered above
After each write, run foamDictionary <case_dir>/<folder>/<file> if available to verify it parses; if it errors, the writer made a syntax mistake — re-write that one file with the error attached.
Stage 6 — Allrun
System prompt (verbatim from Foam-Agent/src/services/input_writer.py: command_system_prompt)
Mesh-type-conditional appendices (verbatim)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcfd-skills/cfd-foamagent/SKILL.md
Popularity
- Repository stars
- 51
- Repository forks
- 6
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/csml-rpi/ai-cfd-scientist/cfd-foamagent)