Skip to content

Feature Request: Agent Delegation Quality Assurance & Verification Protocols #7247

Closed as not planned

Description

@devinbostwick

Summary

Request for built-in verification protocols when delegating tasks to agents to prevent systematic compliance violations in enterprise codebases.

Problem Statement

During enterprise development on opsflow-nextjs, I experienced a critical quality issue where delegated agent tasks resulted in systematic compliance violations across 52 processed components:

  • Export Pattern Violations: Agents used default exports instead of required named exports
  • Import Path Violations: Agents used incorrect hook import paths
  • Structure Violations: Components placed in wrong enterprise directory structure
  • TypeScript Errors: Syntax issues from corrupted string handling

These issues were only caught through a manual "self-audit" request. Without this catch, Phase 4 deployment would have failed completely.

Requested Feature

1. Agent Verification Protocol

Add optional verification requirements to agent delegation:

```
Agent Task with Verification:

  • Process components with enterprise requirements
  • VERIFY: Run npx tsc --noEmit after processing
  • VERIFY: Check export patterns match specified format
  • VERIFY: Validate import paths follow project standards
  • REPORT: Specific verification results before completion
    ```

2. Batch Size Limits

Enforce maximum batch sizes (e.g., 10 items) to enable incremental verification instead of processing all 52 components before discovering systematic errors.

3. Enterprise Context Inheritance

Ensure agents can access and follow project standards files:

  • PROJECT-STANDARDS.md
  • ENTERPRISE-FILE-STRUCTURE.md
  • CONTRIBUTING.md
  • Custom verification checklists

4. Quality Gates

Prevent agents from declaring "ready for next phase" without passing verification requirements.

Business Impact

This would prevent enterprise development failures and reduce manual QA overhead. The "self-audit saved the project" scenario demonstrates this is a critical enterprise development need.

Workaround Currently Used

Created AGENT-DELEGATION-CHECKLIST.md with manual protocols, but built-in Claude Code support would be much more reliable.

Related Files

This feature would significantly improve Claude Code's enterprise development reliability.

Activity

  1. coygeek commented on Sep 6, 2025

    @coygeek

    Hey, this is a great write-up and a super important issue for enterprise use. I've run into similar consistency problems with agents on large-scale refactors, where a small, systematic error gets amplified across dozens of files. It's a critical point for making agents truly reliable.

    While built-in VERIFY steps would be a fantastic addition, I think you can get pretty close to what you're asking for today by combining a few existing features: Subagent Prompts, Memory Imports, and especially Hooks.

    1. For your Verification Protocol & Quality Gates (PostToolUse Hooks)

    This is a perfect use case for Claude Code Hooks. Specifically, you can use a PostToolUse hook that triggers after an agent uses the Edit or Write tool. This hook can run a script to perform your verification checks.

    The best part is that if the script returns a specific exit code (2), it blocks the agent and feeds the script's error output back to Claude as feedback. This acts as your "Quality Gate."

    Here’s how you could set it up:

    a. Create a verification script in your repo, for example .claude/hooks/verify-component.sh:

    #!/bin/bash
    # .claude/hooks/verify-component.sh
    
    # Read the file path from stdin (passed by the hook)
    # Note: The hook provides a JSON object to stdin
    FILE_PATH=$(jq -r '.tool_input.file_path' < /dev/stdin)
    
    # Only run checks on component files
    if [[ "$FILE_PATH" != *"components"* || "$FILE_PATH" != *".tsx"* ]]; then
      exit 0
    fi
    
    ERRORS=""
    
    # --- Your Verification Logic ---
    # Check for default exports
    if grep -q "export default" "$FILE_PATH"; then
      ERRORS+="ERROR: Component uses a default export. Please use named exports.\n"
    fi
    
    # Check for bad hook import paths
    if grep -q "from 'hooks'" "$FILE_PATH"; then
      ERRORS+="ERROR: Invalid import path. Hooks must be imported from '@enterprise/hooks'.\n"
    fi
    
    # Run TSC for type errors
    TSC_OUTPUT=$(npx tsc --noEmit "$FILE_PATH" 2>&1)
    if [ $? -ne 0 ]; then
      ERRORS+="\nTypeScript Errors:\n$TSC_OUTPUT\n"
    fi
    
    # --- Quality Gate ---
    if [ -n "$ERRORS" ]; then
      echo -e "Verification failed for $FILE_PATH:\n$ERRORS" >&2
      exit 2 # Exit code 2 feeds this stderr output back to Claude
    fi
    
    exit 0 # Success

    Make sure to chmod +x .claude/hooks/verify-component.sh

    b. Configure the hook in .claude/settings.json:

    {
      "hooks": {
        "PostToolUse": [
          {
            "matcher": "Edit|Write",
            "hooks": [
              {
                "type": "command",
                "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/verify-component.sh"
              }
            ]
          }
        ]
      }
    }

    Now, every time the agent modifies a component, this script will run. If it fails, the agent will be stopped, shown the errors, and will likely try to fix them on its own.

    2. For Enterprise Context Inheritance

    You're spot on that agents need to reliably follow project standards. The Memory documentation shows you can use a root CLAUDE.md file to import other standards files using the @ syntax. This is more robust than just hoping the agent finds them.

    Your project's CLAUDE.md could look like this:

    # Project Standards
    This project follows strict enterprise development standards.
    
    - Core Contribution Guidelines: @CONTRIBUTING.md
    - Enterprise File Structure Rules: @ENTERPRISE-FILE-STRUCTURE.md
    - Agent Delegation Checklist: @AGENT-DELEGATION-CHECKLIST.md
    
    **IMPORTANT**: All component modifications are automatically verified by a hook. If you receive a 'Verification failed' error, you MUST correct all listed issues before proceeding.

    3. For Batch Size Limits

    This is a tough one. I don't see a direct way to configure this in the docs, and it's a great suggestion. The best workaround I've found is to be explicit in the prompt:

    "Process the first 5 components from the list. After you are done, stop and wait for my confirmation before proceeding with the next batch."

    It's manual, but it prevents the agent from running away with all 52 components before you can spot a systematic error.


    Tying It All Together

    So, a potential workflow could be:

    1. Beef up your sub-agent's system prompt to explicitly mention the verification step and the standards documents.
    2. Use CLAUDE.md with @ imports to ensure all standards are in context.
    3. Implement the PostToolUse hook to act as your automated quality gate.
    4. Prompt the agent to work in smaller batches for large tasks.

    Anyway, hope this helps bridge the gap until the team can build a more native solution. It's definitely a +1 from me on the core feature request!

    P.S. I saw in the latest changelog (v1.0.94) they added a /todos command. Could be useful for having the agent explicitly track and check off components as it processes them in batches.

  2. github-actions commented on Dec 5, 2025

    @github-actions

    This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

  3. github-actions commented on Jan 5, 2026

    @github-actions

    This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

  4. github-actions commented on Jan 14, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  5. locked as resolved and limited conversation to collaborators on Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions