Skip to content

Add Claude skill to implement AMReX and bridge code for a MOM6 Fortran subroutine#15

Merged
johnmauff merged 6 commits into
mainfrom
add_claude_skill
May 23, 2026
Merged

Add Claude skill to implement AMReX and bridge code for a MOM6 Fortran subroutine#15
johnmauff merged 6 commits into
mainfrom
add_claude_skill

Conversation

@sjsprecious

@sjsprecious sjsprecious commented May 7, 2026

Copy link
Copy Markdown
Contributor

This PR adds the Claude skill to implement the AMReX and bridge code for a desired MOM6 Fortran subroutine.

An example of usage in Claude CLI looks like:

/generate_amrex_code <tim_work_directory> <fortran_subroutine_name> [<mom6_work_directory>] [--enable_src_validate] [--enable_git_commit]

An actual example looks like:

/generate_amrex_code /path_to_balabala/TIM ppm_limit_pos /path_to_balabala/MOM6 --enable_src_validate --enable_git_commit

or

/generate_amrex_code /path_to_balabala/TIM ppm_limit_pos /path_to_balabala/MOM6

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Claude skill (/generate_amrex_code) intended to generate the C++/AMReX side of a MOM6 Fortran subroutine bridge within a TURBO-ESM/TIM checkout, along with a companion “lessons learned” document based on TIM PR #8.

Changes:

  • Introduces .claude/skills/generate_amrex_code/SKILL.md as a step-by-step execution checklist for generating bridge/kernel code.
  • Adds .claude/skills/generate_amrex_code/lessons.md documenting patterns/conventions from TIM PR #8 for bridge marshalling, AMReX kernels, and pointwise device primitives.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.claude/skills/generate_amrex_code/SKILL.md Defines the user-invocable skill workflow, validation rules, and generation steps.
.claude/skills/generate_amrex_code/lessons.md Captures established implementation patterns and pitfalls from prior bridge work (PR #8).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

the kernel symbol, the bridge symbol, and the
capture filename.
<mom6-directory> OPTIONAL. Absolute path to a TURBO-ESM/MOM6
checkout. When given, Step 3 grep's the
it writes any C++.

- **If `$2` was supplied**, run
`grep -irln "^[[:space:]]*subroutine[[:space:]]\+\(<function-name>_fortran\|<function-name>\)\b" $2/src $2/config_src`.
Comment on lines +130 to +141
(`MOM::<lowercased_$1>`), bridge symbol
(`<prefix>_<lowercased_$1>_bridge`), target file paths, whether
each will be created or appended, and whether a `*_point` factor
is the working assumption (Step 3 may override it).

### 2. Gather the bridge contract
Ask the user for the Fortran-side `bind(C)` interface, either as
the literal `interface … end interface` block or as a path to a
MOM6 source file containing
`<prefix>_<lowercased_$1>_bridge) bind(C)` (the skill `grep`s the
signature out — if `$2` was supplied, default the search root to
`$2/src` and `$2/config_src`).
Report:

1. Bridge symbol implemented and the kernel symbol it dispatches to.
2. Source-of-truth for the port: file path + line range (if grep'd

@johnmauff johnmauff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjsprecious, I have the same comment here as for the MOM version. How does Claude know about the function '/generate_amrex_code' before it checks out the repol

@sjsprecious

Copy link
Copy Markdown
Contributor Author

@sjsprecious, I have the same comment here as for the MOM version. How does Claude know about the function '/generate_amrex_code' before it checks out the repol

see my reply about the MOM6 Claude skill (TURBO-ESM/MOM6#24).

@johnmauff johnmauff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjsprecious as with the matching PR to the MOM6 repo, I think that the GitHub steps #1 and #12 should be optional, which would allow the user of the script to execute or not.

@sjsprecious

Copy link
Copy Markdown
Contributor Author

@sjsprecious as with the matching PR to the MOM6 repo, I think that the GitHub steps #1 and #12 should be optional, which would allow the user of the script to execute or not.

Thanks @johnmauff . I just pushed the changes you suggested and updated the PR description for the new usage.

@johnmauff johnmauff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjsprecious, thanks for the PR. This looks good to me.

@johnmauff johnmauff merged commit b623934 into main May 23, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants