Returns the conventional directory path where custom agents for a given
coding agent are stored. The path is not expanded (i.e., ~ is not
resolved to the home directory). Use fs::path_expand() if you need an
absolute path.
Usage
agent_path(agent = NULL, scope = c("project", "global"))Arguments
- agent
One of
"claude_code"(or its alias"claude"),"openclaw","codex","cursor","gemini_cli","github_copilot"(or its alias"copilot"), or"posit_ai"(or its alias"posit"). IfNULL(the default), the agent is resolved in order: (1) theWF_AGENTenvironment variable, (2) a scan of the current working directory for a recognised agent config folder (.claude,.cursor, etc.), and (3) a final fallback to"claude_code". SetWF_AGENTin your.Renviron(e.g. withusethis::edit_r_environ()) to avoid passingagentevery time.- scope
One of
"project"(a path relative to the current working directory, suitable for committing to version control) or"global"(a path in the user's home directory, available across all projects).
Examples
agent_path('claude_code', 'project')
#> [1] ".claude/agents"
agent_path('claude', 'project') # alias for claude_code
#> [1] ".claude/agents"
agent_path('cursor', 'global')
#> [1] "~/.cursor/agents"
agent_path() # auto-detects from WF_AGENT, dir scan, or falls back to claude_code
#> [1] ".claude/agents"
