When a Picard repository is cloned, agent mode files (.gitignored) won't be present.
This function checks if agent mode is available and restores it using metadata from existing repo files.
Agent mode provides any coding agent (Claude Code, GitHub Copilot, Cursor, etc.) with study
context through a root AGENTS.md file plus reference docs and skills in .agent/.
Usage
initAgentMode(projectPath = here::here(), verbose = TRUE, reset = FALSE)Arguments
- projectPath
Character. Path to the Picard repository. Defaults to current working directory.
- verbose
Logical. Display informative messages during initialization. Default: TRUE
- reset
Logical. If TRUE, replace any existing agent files with fresh copies from the installed picard (and Capr) version. This deletes
AGENTS.mdand the entire.agent/folder — including any custom files added there — before rewriting them. Use after upgrading picard to pick up new or relocated agent files. Default: FALSE
Value
Invisibly returns a list with:
agent_mode_active: Logical. TRUE if agent mode files are now availablefiles_created: Character vector of files that were created/restoredfiles_removed: Character vector of legacy agent files that were deletedalready_existed: Logical. TRUE if agent mode files already existed
Details
Agent mode setup consists of:
AGENTS.mdat the workspace root (tool-agnostic agent instructions).agent/reference-docs/with detailed study-framework documentation.agent/skills/with task-specific skills, includingpicard-capr-cohortsand, when the Capr package is installed, itscapr-cohort-generationskill bundle
Study metadata is extracted from existing repo files:
Study title and project name from README.md
Tool type from config.yml
Repository name from the repo folder name
Repositories created with picard versions before the .agent/ layout (which used
copilot-instructions.md and .github/reference-docs/) are migrated automatically:
the legacy files and their .gitignore entries are removed whenever this function
writes the new layout, and .agent//AGENTS.md are added to .gitignore if missing.