Paths & Security
Complete guide to path configuration and file access control in Agent.md.
Overview
Agent.md uses a two-level path system:
- Global paths (runtime) — Configure where agents and databases live
- Agent paths (frontmatter) — Declare what each agent can access
Resolution order: CLI → ENV → Defaults
Workspace Structure
Default layout:
~/.config/agentmd/
└── config.yaml # Application settings (auto-created on first run)
~/agentmd/
├── .env # API keys (secrets)
├── agents/
│ ├── agent1.md
│ ├── agent2.md
│ └── mcp-servers.json (optional)
└── data/
└── agentmd.db
Global Paths (Runtime Level)
Four paths can be configured:
| Path | Description | Default |
|---|---|---|
workspace |
Root directory for agents | ~/agentmd |
agents_dir |
Where .md files live |
{workspace}/agents |
db_path |
SQLite execution history | {workspace}/data/agentmd.db |
mcp_config |
MCP servers file | {agents_dir}/mcp-servers.json |
Configuration File
Runtime settings live in ~/.config/agentmd/config.yaml (XDG standard). This file is auto-created with defaults on first run — no manual setup needed.
# ~/.config/agentmd/config.yaml
workspace: ~/agentmd
agents_dir: agents # relative to workspace
defaults:
provider: google
model: gemini-2.5-flash
CLI Arguments (Highest Priority)
agentmd start \
--workspace /path/to/workspace \
--agents-dir /path/to/agents \
--db-path /path/to/db.db
# Available for: start, run, list
Defaults (Lowest Priority)
workspace → ~/agentmd
agents_dir → {workspace}/agents
db_path → {workspace}/data/agentmd.db
mcp_config → {agents_dir}/mcp-servers.json
Resolution Examples
Example 1: All defaults
config → ~/.config/agentmd/config.yaml
workspace → ~/agentmd
agents_dir → ~/agentmd/agents
db_path → ~/agentmd/data/agentmd.db
Example 2: Custom workspace via config.yaml
workspace → /home/alice/my-agents
agents_dir → /home/alice/my-agents/agents
db_path → /home/alice/my-agents/data/agentmd.db
Example 3: Config + CLI (CLI wins)
Agent Paths (Frontmatter Level)
Each agent declares allowed paths in frontmatter. The paths field controls which directories and files the agent can access for reading, writing, and listing.
Configuration
Defaults: [workspace_root] (entire workspace)
Behavior:
- Directory: access all files within (recursive)
- File: access specific file only
- Relative paths resolve from workspace_root (for both reads and writes)
- Absolute paths used as-is
- ~ expanded to home directory
Examples:
# Access entire workspace (default, omit field)
# Single directory
paths: ./data
# Multiple locations
paths:
- ./data
- ./logs
- /var/log/app
- ./output
# Specific files
paths:
- ./config/settings.json
- ./data/input.csv
- ./output/result.txt
Path resolution example:
When agent writes reports/summary.txt:
- Resolves to: workspace root + reports/summary.txt
Security Restrictions
File access is validated before every operation.
Forbidden Paths
Cannot access:
- Agents directory (
workspace/agents) - Prevents reading or modifying agent code
-
Error:
"Access denied: cannot access agents directory" -
.envfiles (any.*env*) - Prevents credential leakage or modification
-
Error:
"Access denied: cannot access .env files" -
.dbfiles (write only) - Prevents database corruption
- Error:
"Access denied: cannot write to .db files"
Watch Triggers
Agents with watch triggers automatically gain access to watched paths:
Explicit paths is combined with watch paths:
trigger:
type: watch
paths:
- ./data/input.txt
paths:
- ./config
- ./output
# Can access ./data/input.txt, ./config, AND ./output
Common Patterns
Minimal Access
Isolated Agent
Multi-Source Agent
Specific File Access
Setup Examples
Development
Use defaults (zero-config):
Structure:
Production
Custom workspace via config:
Structure:
Multi-Workspace
Docker
Best Practices
Principle of Least Privilege
Grant minimum necessary access:
Separate Concerns
Use different directories per agent:
# Agent 1
paths:
- ./data/agent1
- ./output/agent1
# Agent 2
paths:
- ./data/agent2
- ./output/agent2
Use Relative Paths
Prefer relative for portability:
Keep Workspace Self-Contained
Troubleshooting
"No agents found"
Cause: Wrong agents_dir
Fix: Check path:
"Access denied: outside allowed paths"
Cause: Agent tried to access an unlisted path
Fix: Add to paths:
"Access denied: cannot read from agents directory"
Cause: Tried to read workspace/agents
Fix: Move files to readable location:
"Database error"
Cause: db_path directory missing
Fix: Create parent or use a custom path:
"Permission denied"
Cause: No write access to paths
Fix: Use accessible paths:
Related Documentation
- Agent Configuration - All YAML fields and configuration
- Triggers - Watch and schedule triggers
- Quick Start - Setup and installation