Skip to content

Add AGENTS.md agent instructions - #51

Open
roninsightrx wants to merge 3 commits into
mainfrom
add-agents-md
Open

roninsightrx wants to merge 3 commits into
mainfrom
add-agents-md

Conversation

@roninsightrx

Copy link
Copy Markdown
Contributor

Renames CLAUDE.md to AGENTS.md and refreshes its contents.

AGENTS.md is the harness-agnostic filename, so agent harnesses other than Claude Code (Codex, Cursor, Copilot, Gemini CLI, ...) also pick up these instructions. The file itself is written for "AI coding agents" generally rather than for one tool.

What the file contains

  • Package overview — what mipdeval does and its GitHub-only core dependencies (PKPDmap, PKPDsim).
  • Common commands — devtools::load_all(), test(), test(filter = ...), document(), check(), build_readme(), plus vignette/pkgdown builds, and what CI actually runs.
  • Architecture — the run_eval() pipeline end to end: model parsing (S3 dispatch), input validation and the dictionary, per-subject data parsing and the _grouper column, the core iterative loop, the VPC/NPDE step, and the statistics layer.
  • Output structure — the full mipdeval_results element list and the S3 print/plot methods.
  • Key design patterns — typed option helpers, sample weighting, grouping columns, furrr parallelism, progressr/cli progress, and the cli::cli_abort() error style.
  • Data and reference results — lazy-loaded datasets, data-raw/ regeneration, and the PsN proseval reference output used for validation.
  • Test infrastructure — testthat edition 3, the model-library install in setup.R, local_mipdeval_options(), and vdiffr snapshots.

Corrections to the previous content

  • The sample-weighting section described a calculate_fit_weights.R with gradient schemes, which does not exist on main. Weighting is handle_sample_weighting() in run_eval_core.R (cumulative vs. incremental).
  • bootstrap_summ was missing from the documented output list.
  • The empty "Development Rules" heading was dropped.

Also adds AGENTS.md to .Rbuildignore so it is not shipped in the built package.

Docs-only change; no R code is touched.

🤖 Generated with Claude Code

Use the harness-agnostic AGENTS.md filename so agents other than Claude
Code pick up the instructions, and refresh the content against the
current state of the package:

- Correct the sample-weighting section: weighting lives in
  handle_sample_weighting() in run_eval_core.R (cumulative vs.
  incremental), not in a calculate_fit_weights.R with gradient schemes.
- Document the incremental (MPC) fitting mode, covariate censoring, the
  _grouper column, and the required input columns / dictionary rules.
- Add the missing bootstrap_summ element to the documented output list.
- Describe the VPC/NPDE step, the option-helper validation pattern, the
  S3 print/plot methods, the example datasets and PsN reference data.
- Add build_readme()/vignette/pkgdown commands and note what CI runs.
- Drop the empty "Development Rules" heading.

Also add AGENTS.md to .Rbuildignore so it is not shipped in the built
package.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@roninsightrx roninsightrx left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changes requested: two factual claims in AGENTS.md would mislead coding agents.

  • AGENTS.md:66-69 says the input requires only ID, TIME, EVID, and DV. However, parse_nm_data() unconditionally selects CMT in R/parse_input_data.R, so a data set containing only the documented columns fails later in the pipeline; the dictionary also cannot rename CMT. Add CMT to the operational input requirements and clarify the dictionary limitation (or make CMT optional and validate that behavior in code).
  • AGENTS.md:127-129 says print() and plot() methods exist for the top-level result and the stats_summ, shrinkage, and bayesian_impact sub-objects. The namespace registers custom print() methods for those three sub-objects, but plot() only for mipdeval_results. Rewrite this to distinguish the top-level plot() method from the sub-object print() methods.

Reviewed by Codex

- Document that AMT and CMT are required in practice even though
  check_required_cols() only validates ID/TIME/EVID/DV, and that the
  dictionary cannot rename them.
- Distinguish the top-level plot() method from the sub-object print()
  methods; plot() is only defined for mipdeval_results.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@roninsightrx

Copy link
Copy Markdown
Contributor Author

Addressed the Codex review. Both findings verified against source before changing anything.

1. AGENTS.md:66-69 — input column requirements. Confirmed, fixed.
check_required_cols() (R/check_input_data.R) only validates ID/TIME/EVID/DV, but parse_nm_data() (R/parse_input_data.R:59) hard-selects CMT. Reproduced: a dataset without CMT fails with Can't select columns that don't exist. Column `CMT` doesn't exist. Codex also understated it — PKPDsim::nm_to_regimen() aborts with AMT column is required in source dataset!, so AMT is required too. Also confirmed check_valid_dictionary() restricts dictionary names to those same four, so neither AMT nor CMT can be renamed. The section now states all of this.

2. AGENTS.md:127-129 — print()/plot() methods. Confirmed, fixed.
NAMESPACE registers print for mipdeval_results plus the three sub-object classes, but plot only for mipdeval_results. Rewritten to separate the two.

No code changes made — this PR is docs-only, so the CMT/AMT behavior is documented as-is rather than altered.

Note: devtools::test() on this branch reports [ FAIL 6 | WARN 0 | SKIP 2 | PASS 286 ]. These are pre-existing numeric-reference mismatches unrelated to this PR (the branch diff vs main touches only AGENTS.md, CLAUDE.md, .Rbuildignore); the 2 skips are because vdiffr is not installed locally.

🤖 Generated with Claude Code

@roninsightrx roninsightrx left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Approval verdict: all findings are resolved. GitHub does not permit the authenticated PR owner to submit a formal approval, so this is recorded as a review comment.

  • The input section now accurately distinguishes the four columns checked by check_required_cols() from the additional practical AMT and CMT requirements, and correctly records that the dictionary cannot rename those two columns.
  • The method section now accurately states that the result and three summary sub-objects have custom print() methods, while only the top-level mipdeval_results object has a custom plot() method.
  • No harness-specific references or new inaccuracies were introduced.

Reviewed by Codex

@mccarthy-m-g mccarthy-m-g left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm! Just one suggestion. Also, CI is failing because some actual test values no longer match expected, likely due to one of our recent PKPDsim fixes

Comment thread AGENTS.md Outdated
get weight 1), or only the current group when `incremental = TRUE`;
- censors future covariates via `handle_covariate_censoring()` to prevent
data leakage (`censor_covariates = TRUE`; set `FALSE` to reproduce
`PsN::proseval` behaviour exactly);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure if this syntax would confuse an agent into thinking this is an R package/function: PsN::proseval. Maybe rephrase to "PsN's proseval"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — changed to PsN's proseval, which also matches how PsN is referred to on lines 12 and 163; line 87 was the only :: in the file pointing at something that isn't an R package.

Use "PsN's `proseval`" instead of `PsN::proseval`, since the `::`
namespace syntax could read as an R package/function call. PsN is a
Perl toolkit; this also matches how PsN is referred to elsewhere in
the file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@roninsightrx

Copy link
Copy Markdown
Contributor Author

Round 3 — outstanding feedback gathered from reviews, inline threads and conversation comments.

Codex follow-up review: reports all previous findings resolved, so nothing further to do there.

@mccarthy-m-g, AGENTS.md:87 — PsN::proseval reads like an R namespaced call. Fixed.
Changed to PsN's proseval. PsN is a Perl toolkit, not an R package, and this was the only :: in the file pointing at something that isn't one — all the others (devtools::, pkgdown::, PKPDmap::, purrr::, cli::, …) are genuine R packages. It also now matches the phrasing already used on lines 12 and 163.

@mccarthy-m-g, CI failure — out of scope for this PR.
Confirmed: the failing job is ubuntu-latest (release) with [ FAIL 2 | PASS 292 ], both in test-run_eval.R:188 and :203 ("Incremental Bayes method works") — expected numeric values drifting, consistent with the recent PKPDsim fixes. The branch diff against main touches only AGENTS.md, CLAUDE.md and .Rbuildignore, so this is pre-existing and unrelated. Leaving the test values for a separate PR rather than folding a behavioural change into a docs-only one.

No other outstanding items: no other unresolved review threads, and no cross-repo suggestions were raised on this PR. If a shared "basic R package instructions" baseline across repos is something the team wants, that's worth its own discussion rather than settling it here.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants