Troubleshooting
Common failure modes + recovery steps.
Agent output issues
- Partial snippets / missing context: ask for full drop-in function definitions and paste only the relevant current code + errors.
- Over-scoped refactors: restate constraints (“minimal diff”, “no broad refactors”) and narrow the SCOPE to one file/function cluster.
- Brittle tests: prefer asserting on values/classes; only assert message text when it’s part of the user-facing contract.
devtools::document() problems
RoxygenNotechanges unexpectedly: updateDESCRIPTION(let roxygen write it) and commit the change.@exportdidn’t export: confirm the roxygen block is directly above the function and re-rundevtools::document().@importFromnot reflected: preferpkg::funin code; otherwise ensure the roxygen tag is correct.
Test failures
- Non-deterministic tests: remove randomness or set a seed; avoid relying on locale/timezone.
- Snapshot brittleness: prefer checking classes/values over exact messages unless messages are part of the contract.
devtools::check() / R CMD check issues
ERROR: dependencies ... are not available: add missing packages toImports/Suggestsand use explicit namespacing.Namespace in Imports field not imported from: either usepkg::funor add a precise@importFrom.Non-standard file/directory found at top level: keep the Jekyll site indocs/(not package root) when building a package tarball.- Windows path issues: normalize paths (
normalizePath(..., winslash = "/", mustWork = FALSE)), avoid hard-coded drive letters.
Keeping the codebase healthy over time
- Don’t merge without green
devtools::check()(or a documented, justified NOTE). - Keep dependencies intentional; prune unused packages periodically.
- Prefer consistent error classes/messages; treat them as part of the API.
Getting back to a small scope
Paste a handoff summary and restart the thread:
# Project
Package: <pkgname>
Goal: <one sentence>
Branch/version: <...>
# Conventions
<bullets of non-negotiables>
# Current work item
Feature/bug:
Acceptance criteria:
# Code surface area
Files + functions:
# State
Done:
TODO:
Known failing logs:
# Decisions made
<API/testing/behavior decisions>
# Next deliverable
<what you want the agent to produce in the new chat>