Create audit agent

From Alexander-M-Dickerson/ai-asset-pricing · View interactive version

Create audit agent is an AI agent skill from the GitHub repository Alexander-M-Dickerson/ai-asset-pricing. Creates new Claude Code agent configuration files or audits existing ones in .claude/agents/. Validates frontmatter, routing keywords, body-frontmatter alignment, ecosystem integration, and cross-agent consistency using a 17-point checklist.

How to use this skill

Skill file

Agent Creator & Auditor

Two modes: Create a new agent or Audit an existing one.

Examples

Mode Selection

Parse $ARGUMENTS:


CREATE MODE

Five phases: Gather → Reference → Generate → Register → Verify.

Phase 1: Gather Requirements

1a. Scan existing agents

List all .md files in .claude/agents/ to prevent name collisions and understand existing scope.

1b. Ask the user

If $ARGUMENTS contains a name or description, use it. Otherwise, use AskUserQuestion with all of the following:

  1. Name: lowercase-with-hyphens identifier (e.g., my-data-expert)
  2. Purpose: What domain does this agent cover? What databases, tables, or APIs does it work with?
  3. Key routing terms: What keywords should trigger delegation? (database names, table names, acronyms, paper names)
  4. Tools needed: What tools should the agent have? (read-only vs full access, specific tools)
  5. Skills: Should any skills be injected at startup? (e.g., wrds-psql)
  6. Model: inherit (default), sonnet, opus, or haiku?

1c. Skill vs Agent decision

Before proceeding, ask: "Is this a known, rigid workflow with fixed inputs?" If yes, recommend a skill (/create-skill) instead. Agents are for tasks requiring judgment, discovery, or error recovery. Skills run in the caller's context with zero spawn overhead (75-80% fewer tokens). See docs/AGENT_LESSONS_LEARNED.md for rationale.

1d. Check for overlap

Compare the user's answers against existing agents. If there's scope overlap (same tables, same databases), warn the user and ask whether to:

Phase 2: Generate

Build the agent .md file:

Frontmatter:

---
name: [validated name]
description: "[WHAT + WHEN statement with 3 <example> blocks including <commentary>]"
tools: [appropriate tool list]
model: [inherit unless specified]
---

Description requirements:

Body structure:

You are [role description matching frontmatter scope].

**Before running any psql query, invoke the `wrds-psql` skill** [if applicable]

## Overview
[Domain knowledge, key paper references, data sources]

## Table(s)
[Schema.table names with brief descriptions]

## Database Connection
[Connection pattern]

## [Domain-Specific Sections]
[Filters, identifiers, signal names, etc.]

## Example Queries
[2+ tested query patterns with explanations]

## Gotchas
[Data quality issues, common mistakes, edge cases]

Body rules:

3b. Show draft

Print the complete agent file to the user before writing. Ask if they want changes.

3c. Write

Write to .claude/agents/{name}.md.

Phase 3: Register

4a. CLAUDE.md

Add the agent to the specialist agent list in root CLAUDE.md under "WRDS Database Access" (for WRDS agents) or appropriate section.

4b. Orchestrator dispatch table

If this is a WRDS agent, add a row to .claude/agents/wrds-query-orchestrator.md in the "Specialized Agents Available" table.

Print confirmation:

Agent created: .claude/agents/{name}.md
Lines: {count}
Registered in: CLAUDE.md, wrds-query-orchestrator.md

Phase 4: Verify

Run the full 17-point audit checklist (from Audit Mode below) against the new agent. Report results. Fix any FAIL items before considering the skill complete.


AUDIT MODE

Four phases: Read → Analyze → Report → Fix.

Phase 1: Read

Parse the audit target from $ARGUMENTS:

Also read:

Phase 2: Analyze

Run 17 checks grouped in 5 categories. For each: PASS, WARN, or FAIL.

A. Frontmatter Quality

A1. Name Valid
A2. Description Present
A3. Description Has Examples
A4. Routing Keywords Present

Scan body for database names, schema.table patterns (e.g., contrib.global_factor, crsp.dsf), key acronyms, and paper/author names. Check if each appears in the description.

A5. Tools Field

B. Body-Frontmatter Alignment

B6. Scope Match

Compare body opening paragraph with frontmatter description scope.

B7. Keyword Coverage

Extract all schema.table patterns, database identifiers, acronyms, and domain terms from body. Compute what percentage appear in description.

B8. No Orphan Knowledge

Check if body contains substantial documentation for databases/tools/workflows NOT mentioned in the description.

C. Body Quality

C9. Skill Invocation
C10. Structured Sections

Check for organized sections with headers.

C11. Example Queries
C12. Line Count & Token Efficiency

Every line in an agent body is loaded on every spawn. Treat agent definitions like hot code paths.

C13. Anti-Patterns

Check for: Windows-style backslash paths, verbose explanations of fundamentals Claude already knows, magic numbers without justification, menus without defaults.

D. Ecosystem Integration

D14. CLAUDE.md Registration

Check root CLAUDE.md for the agent under the specialist agent section.

D15. Orchestrator Dispatch Table

For WRDS agents only: check .claude/agents/wrds-query-orchestrator.md dispatch table.

E. Cross-Agent Consistency

E16. Scope Overlap

Compare this agent's documented tables/schemas against all other agents.

E17. Tool Allocation Consistency & Minimality

Each unused tool adds ~200 tokens of JSON schema to every spawn. Start minimal, add only when needed.

Phase 3: Report

Print structured report:

AGENT AUDIT: {name}
=============================
File: .claude/agents/{name}.md | Lines: {count} | Model: {model}

A. FRONTMATTER          B. ALIGNMENT           C. BODY QUALITY
[PASS] A1 Name          [PASS] B6 Scope        [PASS] C9  Skill invocation
[PASS] A2 Description   [WARN] B7 Keywords     [PASS] C10 Sections
[PASS] A3 Examples      [PASS] B8 Orphans      [PASS] C11 Examples
[FAIL] A4 Routing                               [PASS] C12 Lines ({n})
[PASS] A5 Tools                                 [PASS] C13 Anti-patterns

D. ECOSYSTEM            E. CONSISTENCY
[PASS] D14 CLAUDE.md    [PASS] E16 Overlap
[PASS] D15 Orchestrator [PASS] E17 Tools

SUGGESTIONS:
1. [A4] Add "contrib.global_factor" and "JKP" to description — these
   key body terms are missing from routing metadata.
2. [B7] Keyword coverage is 75% — consider surfacing "permno",
   "gvkey" in description.

RESULT: 15/17 passed, 1 warning, 1 failure

For all mode, print each agent's report separately, then a summary table:

SUMMARY: {N} agents audited
==============================
| Agent                       | Pass | Warn | Fail |
|-----------------------------|------|------|------|
| crsp-wrds-expert            |  16  |   1  |   0  |
| jkp-wrds-expert             |  17  |   0  |   0  |
| bonds-wrds-expert           |  15  |   1  |   1  |
| ff-wrds-expert              |  16  |   0  |   1  |
| optionmetrics-wrds-expert   |  17  |   0  |   0  |
| taq-wrds-expert             |  16  |   1  |   0  |
| paper-reader                |  15  |   2  |   0  |
| wrds-query-orchestrator     |  16  |   1  |   0  |

Phase 4: Fix (Optional)

After reporting, offer to fix FAIL items:

Never auto-fix without showing the proposed change first.


Communication Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.