OpenClaw Agent Reconciliation Skill
Overview
This skill enables systematic reconciliation between the filesystem agent definitions (AGENTS.md files under agent-companies-core/agents/openclawforge-ai/agents/) and the OpenClaw SQLite database tables (openclaw_agents, openclaw_agent_skills, openclaw_agent_models, openclaw_agent_capabilities) that power the OpenClaw control plane.
Trigger Conditions
- User asks to "reconcile agents"
- User asks to "check agents against database"
- User asks to "verify agent registrations"
- User asks to "audit agent names"
- User asks to "validate naming conventions"
- User asks to "find missing agents" or "find extra agents"
- User asks to "generate agent fix SQL"
- User asks to "sync agents to database"
Execution Workflow
Step 0: Schema Validation (MANDATORY)
Before generating ANY SQL, validate the schema:
Query the openclaw_agents table schema:
PRAGMA table_info(openclaw_agents);
Verify columns match expected from schema/create-openclaw-tables.sql:
id, name, slug, role, reports_to, description, skills, company, status, adapter_type, adapter_config, runtime_config, budget_monthly_cents, spent_monthly_cents, last_heartbeat_at, capabilities, metadata, created_at, updated_at
CRITICAL: The openclaw_agents table has:
name = human-readable agent name (e.g., "OpenClaw Agent Reconciler")
slug = agent identifier (e.g., "openclaw-ai-agent-reconciler")
company = company namespace (e.g., "openclawforge-ai")
Step 1: Filesystem Discovery
- Scan
agent-companies-core/agents/openclawforge-ai/agents/**/AGENTS.md
- Parse YAML frontmatter for each agent
- Extract:
name, slug, reportsTo, role, description, skills
- Build filesystem agent index
Step 2: Database Discovery
- Query
openclaw_agents table → all rows
- Query
openclaw_agent_skills table → skill assignments by agent_id
- Query
openclaw_agent_models table → model assignments by agent_id
- Build database agent index
Step 3: Reconciliation Match
- Match filesystem agents to database agents by
slug ↔ slug
- Identify missing agents: in filesystem, not in database
- Identify extra agents: in database, not in filesystem
- Identify field mismatches: name, role, reports_to, description differences
- Identify missing skill assignments
- Identify missing model assignments
- Identify naming convention violations
Step 4: SQL Fix Generation
Generate SQL INSERT/UPDATE/DELETE statements:
| Issue Type |
SQL Operation |
| Missing agent |
INSERT INTO openclaw_agents |
| Extra agent |
DELETE FROM openclaw_agents (FK cascade) |
| Field mismatch |
UPDATE openclaw_agents |
| Missing skill |
INSERT INTO openclaw_agent_skills |
| Missing model |
INSERT INTO openclaw_agent_models |
Step 5: Collaboration Delegation
- Database operations → delegate to
openclaw-ai-sqlite-manager
- Agent creation logic → delegate to
openclaw-ai-agent-creator
- Model assignment logic → delegate to
openclaw-ai-model-assigner
Step 6: Report Output
- Save SQL to
reconciliation_fixes.sql
- Save JSON report to
reconciliation_report.json
- Print summary with counts per table
Input Parameters
| Parameter |
Type |
Required |
Description |
agents_dir |
string |
No |
Path to agents directory (default: agent-companies-core/agents/openclawforge-ai/agents) |
db_path |
string |
No |
Path to SQLite database (default: schema/openclaw-app.db) |
output_sql_path |
string |
No |
Path for SQL output (default: reconciliation_fixes.sql) |
dry_run |
boolean |
No |
If true, only report without generating SQL |
Error Handling
- Missing agents directory: Report error and exit
- Database connection failure: Report error with connection details
- Malformed AGENTS.md: Log warning, skip file, continue
- No database agents: Report warning but continue with filesystem scan
Skill Name: openclaw-ai-agent-reconciler
Version: 1.0
Owner: openclaw-ai-agent-reconciler
Created: 2026-05-01
1---2name: openclaw-ai-agent-reconciler3description: Audit filesystem agent definitions (AGENTS.md) against the OpenClaw SQLite database (openclaw_agents, openclaw_agent_skills, openclaw_agent_models, openclaw_agent_capabilities tables). Identify missing registrations, extra database entries, field mismatches, and naming convention violations. Generate SQL fixes via collaboration with SQLite Manager.4---56# OpenClaw Agent Reconciliation Skill78## Overview910This skill enables systematic reconciliation between the filesystem agent definitions (AGENTS.md files under `agent-companies-core/agents/openclawforge-ai/agents/`) and the OpenClaw SQLite database tables (`openclaw_agents`, `openclaw_agent_skills`, `openclaw_agent_models`, `openclaw_agent_capabilities`) that power the OpenClaw control plane.1112## Trigger Conditions1314- User asks to "reconcile agents"15- User asks to "check agents against database"16- User asks to "verify agent registrations"17- User asks to "audit agent names"18- User asks to "validate naming conventions"19- User asks to "find missing agents" or "find extra agents"20- User asks to "generate agent fix SQL"21- User asks to "sync agents to database"2223## Execution Workflow2425### Step 0: Schema Validation (MANDATORY)2627Before generating ANY SQL, validate the schema:28291. Query the `openclaw_agents` table schema:30 ```sql31 PRAGMA table_info(openclaw_agents);32 ```33342. Verify columns match expected from `schema/create-openclaw-tables.sql`:35 - `id`, `name`, `slug`, `role`, `reports_to`, `description`, `skills`, `company`, `status`, `adapter_type`, `adapter_config`, `runtime_config`, `budget_monthly_cents`, `spent_monthly_cents`, `last_heartbeat_at`, `capabilities`, `metadata`, `created_at`, `updated_at`36373. **CRITICAL**: The `openclaw_agents` table has:38 - `name` = human-readable agent name (e.g., "OpenClaw Agent Reconciler")39 - `slug` = agent identifier (e.g., "openclaw-ai-agent-reconciler")40 - `company` = company namespace (e.g., "openclawforge-ai")4142### Step 1: Filesystem Discovery43441. Scan `agent-companies-core/agents/openclawforge-ai/agents/**/AGENTS.md`452. Parse YAML frontmatter for each agent463. Extract: `name`, `slug`, `reportsTo`, `role`, `description`, `skills`474. Build filesystem agent index4849### Step 2: Database Discovery50511. Query `openclaw_agents` table → all rows522. Query `openclaw_agent_skills` table → skill assignments by `agent_id`533. Query `openclaw_agent_models` table → model assignments by `agent_id`544. Build database agent index5556### Step 3: Reconciliation Match57581. Match filesystem agents to database agents by `slug` ↔ `slug`592. Identify **missing agents**: in filesystem, not in database603. Identify **extra agents**: in database, not in filesystem614. Identify **field mismatches**: name, role, reports_to, description differences625. Identify **missing skill assignments**636. Identify **missing model assignments**647. Identify **naming convention violations**6566### Step 4: SQL Fix Generation6768Generate SQL INSERT/UPDATE/DELETE statements:6970| Issue Type | SQL Operation |71|------------|---------------|72| Missing agent | INSERT INTO openclaw_agents |73| Extra agent | DELETE FROM openclaw_agents (FK cascade) |74| Field mismatch | UPDATE openclaw_agents |75| Missing skill | INSERT INTO openclaw_agent_skills |76| Missing model | INSERT INTO openclaw_agent_models |7778### Step 5: Collaboration Delegation7980- **Database operations** → delegate to `openclaw-ai-sqlite-manager`81- **Agent creation logic** → delegate to `openclaw-ai-agent-creator`82- **Model assignment logic** → delegate to `openclaw-ai-model-assigner`8384### Step 6: Report Output8586- Save SQL to `reconciliation_fixes.sql`87- Save JSON report to `reconciliation_report.json`88- Print summary with counts per table8990## Input Parameters9192| Parameter | Type | Required | Description |93|-----------|------|----------|-------------|94| `agents_dir` | string | No | Path to agents directory (default: `agent-companies-core/agents/openclawforge-ai/agents`) |95| `db_path` | string | No | Path to SQLite database (default: `schema/openclaw-app.db`) |96| `output_sql_path` | string | No | Path for SQL output (default: `reconciliation_fixes.sql`) |97| `dry_run` | boolean | No | If true, only report without generating SQL |9899## Error Handling100101- **Missing agents directory**: Report error and exit102- **Database connection failure**: Report error with connection details103- **Malformed AGENTS.md**: Log warning, skip file, continue104- **No database agents**: Report warning but continue with filesystem scan105106---107108**Skill Name**: openclaw-ai-agent-reconciler109**Version**: 1.0110**Owner**: openclaw-ai-agent-reconciler111**Created**: 2026-05-01