csml-rpi/ai-cfd-scientist/cfd-foamagent

Claude Code and agent skill by csml-rpi/ai-cfd-scientist

Trust tier 2
  • community
LLM review pending
Source check pending

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-foamagent

SKILL.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

PathUse when
cfd-experiment sweep modeYou 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 (per skills/cfd-orchestrator/SKILL.md non-negotiable constraints). When mesh_type=custom_mesh or mesh_type=copied_case and the source is a starter case, copy the case into <case_dir>/ first via cp -r, then edit the copy. Never sed -i, > file, or otherwise mutate any path under the starter directory.
  • max_loop (optional, default 10) — review-rewrite-rerun cap
  • case_stats (optional) — {case_domain: [...], case_category: [...], case_solver: [...]}. If not supplied, the agent infers from the FoamAgent FAISS corpus or from Foam-Agent/database/raw/openfoam_case_stats.json if it exists.

Outputs

  • <case_dir>/ — full OpenFOAM case (mesh, fields, logs, postProcessing)
  • <case_dir>/run_result.json:
json
{
"status": "success | failed | timeout",
"case_dir": "...",
"case_name": "backward_facing_step",
"case_solver": "simpleFoam",
"loop_count": 1,
"wall_time_s": 1234.5,
"error_logs": []
}
  • Optional sidecar: <case_dir>/.foamagent_state.json capturing per-loop summary.

Loop overview

[1] Parse requirement — apply parse_system_prompt → case_info {name, domain, category, solver}
[2] RAG retrieval — scripts/rag_query.py against three indices → tutorial_reference, allrun_reference, dir_structure
[3] Decompose to subtasks — apply decompose_system_prompt → list of (file_name, folder_name)
[4] Mesh routing — choose standard / custom / gmsh / copied path
[5] For each subtask: — apply INITIAL_WRITE_SYSTEM_PROMPT → write file
[6] Allrun — apply command_system_prompt → write Allrun, chmod +x
[7] Run — bash <case>/Allrun, capture log
[8] If failure, REVIEW: — apply REVIEWER_SYSTEM_PROMPT → review_analysis
— apply planner_system_prompt → rewrite plan {target_files: [...]}
— apply EDIT_WRITE_SYSTEM_PROMPT to each → rewrite files
— re-run [7]; loop max max_loop times
[9] Write run_result.json

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)
Please transform the following user requirement into a standard case description using a structured format.
The key elements should include case name, case domain, case category, and case solver.
Note: case domain must be one of {case_domain_list}.
Note: case category must be one of {case_category_list}.
Note: case solver must be one of {case_solver_list}.
User prompt
User requirement: {user_requirement}.
Output schema
json
{
"case_name": "<string>",
"case_domain": "<one of case_domain_list>",
"case_category": "<one of case_category_list>",
"case_solver": "<one of case_solver_list>"
}

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:

bash
# 1. similar full case content (writer + reviewer reference)
python scripts/rag_query.py \
--db openfoam_tutorials_details \
--query "{case_solver} {user_requirement}" \
--top 3 \
--output <case_dir>/.foamagent_state.tutorials.json
# 2. directory structure of similar cases (planner reference)
python scripts/rag_query.py \
--db openfoam_tutorials_structure \
--query "{case_solver} {case_domain} {case_category}" \
--top 3 \
--output <case_dir>/.foamagent_state.dir.json
# 3. Allrun scripts of similar cases
python scripts/rag_query.py \
--db openfoam_allrun_scripts \
--query "{case_solver} {user_requirement}" \
--top 3 \
--output <case_dir>/.foamagent_state.allrun.json

If FAISS indices don't exist (scripts/rag_query.py returns rc=2), build them first:

bash
python Foam-Agent/init_database.py

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 by find $WM_PROJECT_DIR/tutorials/<solver> -maxdepth 2 -type d | head -5).
  • Quality is lower but the writer still works; flag rag_fallback: true in run_result.json.

Stage 3 — Decompose into subtasks

System prompt (verbatim from Foam-Agent/src/services/plan.py: decompose_system_prompt)
You are an experienced Planner specializing in OpenFOAM projects.
Your task is to break down the following user requirement into a series of smaller, manageable subtasks.
For each subtask, identify the file name of the OpenFOAM input file (foamfile) and the corresponding folder name where it should be stored.
Your final output must strictly follow the JSON schema below and include no additional keys or information:
{
"subtasks": [
{ "file_name": "<string>", "folder_name": "<string>" }
// ... more subtasks
]
}
Make sure that your output is valid JSON and strictly adheres to the provided schema.
Make sure you generate all the necessary files for the user's requirements.
User prompt
User Requirement: {user_requirement}
Reference Directory Structure (similar case): {dir_structure}
{dir_counts_str}
Make sure you generate all the necessary files for the user's requirements.
Do not include any gmsh files like .geo etc. in the subtasks.
Only include blockMesh or snappyHexMesh if the user hasn't requested for gmsh mesh or user isn't using an external uploaded custom mesh.
Please generate the output as structured JSON.

Where:

  • {dir_structure} — the top hit from openfoam_tutorials_structure (read from .foamagent_state.dir.json)
  • {dir_counts_str} — small summary like 0/ 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_typeAction
standard_mesh (default)Include a system/blockMeshDict subtask. Allrun will run blockMesh.
custom_meshUser supplied <case_dir>/constant/polyMesh/. Skip blockMeshDict. Allrun should run only the solver (and optionally checkMesh).
gmshUser 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_caseThe 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)
You are an expert in OpenFOAM simulation and numerical modeling.
Your task is to generate a complete and functional file named: <file_name>{file_name}</file_name> within the <folder_name>{folder_name}</folder_name> directory.
Ensure all required values are present and match with the files content already generated.
Before finalizing the output, ensure:
- All necessary fields exist (e.g., if `nu` is defined in `constant/transportProperties`, it must be used correctly in `0/U`).
- Cross-check field names between different files to avoid mismatches.
- Ensure units and dimensions are correct for all physical variables.
- Ensure case solver settings are consistent with the user's requirements. Available solvers are: {case_solver}.
Provide only the code—no explanations, comments, or additional text.
User prompt template
User requirement: {user_requirement}
Tutorial reference (similar case content):
{tutorial_reference}
Already-written files in this case (for cross-referencing):
{written_files_ctx}
Generate <file_name>{file_name}</file_name> in <folder_name>{folder_name}</folder_name>.
Output only the file body — no markdown fences, no explanations.

Where:

  • {tutorial_reference} — concatenation of top-3 hits from openfoam_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:

  1. system/controlDict (sets the application name everything else aligns to)
  2. system/fvSchemes, system/fvSolution
  3. constant/transportProperties (or constant/physicalProperties, constant/cloudProperties, etc., depending on solver)
  4. constant/momentumTransport (for RANS) or constant/turbulenceProperties (legacy naming)
  5. system/blockMeshDict (if mesh_type=standard_mesh)
  6. 0/<field> files (one per field declared in controlDict/transportProperties/turbulence model)
  7. 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)
You are an expert in OpenFOAM. The user will provide a list of available commands.
Your task is to generate only the necessary OpenFOAM commands required to create an Allrun script for the given user case, based on the provided directory structure.
Return only the list of commands—no explanations, comments, or additional text.
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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/csml-rpi/ai-cfd-scientist/cfd-foamagent/badge)](https://verified-skill.com/skills/csml-rpi/ai-cfd-scientist/cfd-foamagent)

Something wrong with this skill or its page? Tell us.