Installs a custom agent from a GitHub repository or a local file into an
agents directory. Agents are single Markdown files with YAML frontmatter
specifying at minimum a name and description.
Arguments
- source
One of:
A GitHub URL pointing to a repo, e.g.
"https://github.com/owner/repo".A GitHub URL pointing to a subdirectory or file, e.g.
"https://github.com/owner/repo/tree/main/path/to/agent.md".A GitHub shorthand, e.g.
"owner/repo".A local file path pointing to a Markdown file.
- agent
The agent to install. One of:
A bare agent name (without
.md), e.g."code-reviewer". The agent is read fromagents/<agent>.mdwithin the repository.A path to the agent file, e.g.
"r-lib/mirai/AGENT.md"or"r-lib/mirai/". Used directly as the path within the repository. Ignored whensourcealready points to a specific path via/tree/...or/blob/....
- path
The agents directory. Can be one of:
A known coding agent name such as
'claude_code','cursor', or'github_copilot'(seeagent_path()for the full list) to use that agent's conventional project-scope path.A character string giving the directory path directly.
NULL(the default), in which case the path is resolved from theWF_AGENTenvironment variable, or by prompting in interactive sessions. SetWF_AGENTin your.Renviron(e.g. withusethis::edit_r_environ()) to avoid the prompt.
- overwrite
If
FALSE(the default), an error is raised if the agent is already installed. Set toTRUEto replace it.
Examples
src <- tempfile(fileext = '.md')
writeLines(
c('---', 'name: example', 'description: An example agent.', '---'),
src
)
add_agent(src, path = tempfile())
#> Installed agent "example" to /tmp/Rtmplehrfy/file196d52a3ff90/example.md.
