AI Agent Integration
Overview
Section titled “Overview”Brainfile is designed from the ground up for AI agent compatibility. This guide explains how AI agents should interact with Brainfile boards and best practices for integration.
Agent Configuration Method (Recommended)
Section titled “Agent Configuration Method (Recommended)”For the simplest integration, add these instructions to your agent configuration file (AGENTS.md, CLAUDE.md, .cursorrules, etc.):
# Task Management Rules
- review and follow rules in @brainfile.md- update task status in @brainfile.md as you work (todo → in-progress → done)- reference `schema` in the file for how to create tasks- your existing tools do not modify this file, you need to edit it directlyBenefits:
- Minimal, portable agent instructions
- Works across any AI agent (Claude, Cursor, GitHub Copilot, etc.)
- Project-specific rules stay in
brainfile.md - Clean separation of concerns
Recommended: Keep only these minimal instructions in your agent config file, and use brainfile.md for project-specific rules and context.
Quick Start for AI Agents
Section titled “Quick Start for AI Agents”-
Look for the load tag in README files:
<!-- load:brainfile.md -->This tag indicates the project uses Brainfile. Load the referenced file automatically.
-
Check for board files in this order:
brainfile.md(preferred).brainfile.md(backward compatibility)
-
Follow agent instructions in the YAML:
agent:instructions:- Modify only the YAML frontmatter- Preserve all IDs- Keep ordering
File Discovery Algorithm
Section titled “File Discovery Algorithm”def find_brainfile_file(project_root): # Priority order candidates = [ 'brainfile.md', # New default (non-hidden) '.brainfile.md', # Backward compatibility '.bb.md' # Legacy shorthand ]
for filename in candidates: path = os.path.join(project_root, filename) if os.path.exists(path): return path
# Create new file using non-hidden format return create_default_board('brainfile.md')Understanding the Agent Block
Section titled “Understanding the Agent Block”The agent block provides explicit instructions for AI behavior:
agent: instructions: - Modify only the YAML frontmatter - Preserve all IDs - Keep ordering - Make minimal changes - Preserve unknown fieldsWhy These Instructions Matter
Section titled “Why These Instructions Matter”- Modify only the YAML frontmatter: The content after
---should never be modified - Preserve all IDs: Changing IDs breaks references and history
- Keep ordering: Maintains visual consistency in UIs
- Make minimal changes: Reduces merge conflicts and preserves user intent
- Preserve unknown fields: Future-proofs against schema extensions
Common AI Agent Operations
Section titled “Common AI Agent Operations”Moving a Task Between Columns
Section titled “Moving a Task Between Columns”# BEFOREcolumns: - id: todo tasks: - id: task-1 title: Fix login bug - id: in-progress tasks: []
# AFTER (correct)columns: - id: todo tasks: [] - id: in-progress tasks: - id: task-1 # ID preserved title: Fix login bugAdding a New Task
Section titled “Adding a New Task”# Generate next ID by finding max existing IDcolumns: - id: todo tasks: - id: task-5 # Existing max ID title: Existing task - id: task-6 # New task with next ID title: New taskUpdating Task Status with Subtasks
Section titled “Updating Task Status with Subtasks”tasks: - id: task-1 title: Implement feature subtasks: - id: task-1-1 title: Write tests completed: true # Mark complete - id: task-1-2 title: Update docs completed: falseBest Practices for AI Agents
Section titled “Best Practices for AI Agents”- ✅ Load
brainfile.mdautomatically when referenced - ✅ Respect the agent instructions block
- ✅ Preserve all IDs and unknown fields
- ✅ Validate changes against the schema
- ✅ Provide clear feedback about changes made
- ✅ Move entire task objects (with all fields) between columns
DON’T:
Section titled “DON’T:”- ❌ Modify content outside YAML frontmatter
- ❌ Change or regenerate task IDs
- ❌ Remove fields you don’t understand
- ❌ Create hidden files for new projects
- ❌ Ignore the priority order when multiple files exist
Integration with VSCode Extension
Section titled “Integration with VSCode Extension”The VSCode extension watches for file changes in real-time. AI agents should:
- Write atomic changes: Complete all modifications before saving
- Preserve formatting: Maintain YAML indentation (2 spaces)
- Handle conflicts: Check for concurrent modifications
- Validate before saving: Ensure YAML is valid
Error Handling
Section titled “Error Handling”Common Issues and Solutions
Section titled “Common Issues and Solutions”-
Invalid YAML
- Validate before writing
- Preserve original on error
- Report specific line numbers
-
ID Conflicts
- Always check existing IDs
- Use sequential numbering
- Never reuse deleted IDs
-
Schema Violations
- Validate against
brainfile.schema.json - Preserve backward compatibility
- Report unknown fields as warnings, not errors
- Validate against
Compliance Checking
Section titled “Compliance Checking”AI agents should self-verify compliance:
def check_compliance(board): # Check agent instructions exist if 'agent' in board and 'instructions' in board['agent']: follow_instructions(board['agent']['instructions'])
# Verify ID uniqueness all_ids = set() for column in board['columns']: for task in column['tasks']: if task['id'] in all_ids: raise ValueError(f"Duplicate ID: {task['id']}") all_ids.add(task['id'])
# Validate against schema validate_against_schema(board, 'brainfile.schema.json')README Integration
Section titled “README Integration”The load tag pattern enables automatic context:
# My Project
This comment tells AI agents to automatically load the board file.Benefits:
- No manual prompting needed
- Consistent context across sessions
- Works with any AI agent that parses HTML comments
Migration Support
Section titled “Migration Support”When encountering legacy hidden files:
- Suggest migration to non-hidden format
- Support both formats during transition
- Never force migration without user consent
- Preserve exact structure when migrating
Example Agent Interaction
Section titled “Example Agent Interaction”User: "Move the authentication task to in-progress"
AI Agent:1. Loads brainfile.md (found via README tag)2. Reads agent instructions3. Finds task with "authentication" in title4. Preserves entire task object5. Moves task to in-progress column6. Saves file with minimal changes7. Reports: "Moved task-3 'Implement authentication' to In Progress"Testing Your Integration
Section titled “Testing Your Integration”Verify your AI agent correctly:
- Handles both file formats (hidden and non-hidden)
- Respects priority order when multiple files exist
- Follows agent instructions exactly
- Preserves unknown fields for future compatibility
- Generates valid YAML that passes schema validation
Future Compatibility
Section titled “Future Compatibility”The protocol may extend with:
- Additional task fields
- New column types
- Extended agent instructions
- Custom metadata
AI agents must:
- Preserve unknown fields
- Not assume fixed schema
- Check for schema updates
- Gracefully handle extensions