View source: R/agent_context.R
| agent_context | R Documentation |
Returns assembled context (memory, project/global instructions, agent identity files) tailored to a specific consumer. Files autoloaded by the agent natively are skipped to avoid duplication.
agent_context(
agent = NULL,
project_dir = getwd(),
workspace_dir = NULL,
memory_base = file.path(path.expand("~"), ".claude", "projects"),
claude_global_path = file.path(path.expand("~"), ".claude", "CLAUDE.md"),
include_memory = NULL,
include_project = NULL,
include_global = NULL,
include_soul = NULL,
max_memory_lines = 100L
)
agent |
Consumer identifier: |
project_dir |
Project directory to scan for CLAUDE.md / AGENTS.md. |
workspace_dir |
Optional directory containing SOUL.md and USER.md
(e.g. |
memory_base |
Base directory for 'Claude Code' project memory files. |
claude_global_path |
Path to the global 'Claude Code' instructions
file. Defaults to |
include_memory |
Override default for memory inclusion. Use
|
include_project |
Override default for project instructions (CLAUDE.md / AGENTS.md). |
include_global |
Override default for global instructions (~/.claude/CLAUDE.md / USER.md). |
include_soul |
Override default for SOUL.md inclusion. |
max_memory_lines |
Maximum lines to include from each memory source. |
Defaults per agent:
"claude" - skips Claude Code project memory and CLAUDE.md
files (autoloaded by 'Claude Code'). Loads Codex memories, AGENTS.md,
USER.md, and SOUL.md when present.
"codex" - skips AGENTS.md and Codex memories (autoloaded by
Codex). Loads Claude Code project memory, CLAUDE.md, USER.md, and
SOUL.md when present.
"corteza" or NULL - loads everything available.
Project instructions merge CLAUDE.md and AGENTS.md. The
file the consumer autoloads is left out, and so is any heading-delimited
section whose text the consumer already holds. Two names for one file, or
two identical copies, add nothing; a consumer with no autoloaded file
receives CLAUDE.md followed by the sections only AGENTS.md
has. Sections are compared verbatim, so the same rule in different words
is loaded from both files.
Global instructions are resolved by trying both naming conventions and
picking the file relevant to the consumer: ~/.claude/CLAUDE.md or
<workspace_dir>/USER.md.
Override the defaults with the include_* parameters.
Character string of assembled context, or empty string if no context applies.
# Codex agent in current project
saber::agent_context(agent = "codex")
# Corteza with workspace files
saber::agent_context(agent = "corteza",
workspace_dir = "~/.corteza/workspace")
# Force-include memory regardless of agent default
saber::agent_context(agent = "claude", include_memory = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.