$npx -y skills add GoogleCloudPlatform/cxas-scrapi --skill cxas-protocol-robust-extractionA robust methodology for LLM-based requirements gathering and high-fidelity artifact generation. Employs 'Divide, Conquer, and Verify' tactics using specialized subagents, iterative exhaustion loops, and batched execution to ensure zero data loss.
| 1 | # Robust Extraction Protocol |
| 2 | |
| 3 | This protocol defines the standard operating procedure for extracting exhaustive |
| 4 | requirements (like subintents, CUJs, or logic rules) from large, complex, or |
| 5 | fragmented customer artifacts. |
| 6 | |
| 7 | It prevents the common LLM pitfalls of "context drift" and "truncation" by |
| 8 | enforcing a strict "Divide, Conquer, and Verify" methodology. |
| 9 | |
| 10 | ## General Principles & Anti-Hallucination Guardrails |
| 11 | |
| 12 | To ensure 100% coverage and prevent data loss due to tool limits or implicit |
| 13 | filtering, follow these principles across all phases: |
| 14 | |
| 15 | * **Quantify the Scope**: Before spawning any subagents or starting |
| 16 | extraction, determine the exact total count of target items (files, |
| 17 | directories, database rows). Record this number as your "Success Target." |
| 18 | You must verify that the sum of items processed equals this target before |
| 19 | proceeding to consolidation. |
| 20 | * **Coverage over Curation**: Default to 100% extraction coverage. Never |
| 21 | assume the user only wants the "top" or "most interesting" items unless |
| 22 | explicitly instructed to apply a quality filter. A standard or repetitive |
| 23 | item is still data that must be reported. |
| 24 | * **Circumvent Tool Caps**: Be aware that search and listing tools often have |
| 25 | display limits (e.g., capped at 50 or 1000 results). If the expected scale |
| 26 | (from the Quantify step) exceeds the tool's limit, you must partition the |
| 27 | work (e.g., by alphabet or ID range) to ensure no items are hidden by the |
| 28 | tool's cap. |
| 29 | * **Maintain Traceability**: For every extracted requirement or item, record |
| 30 | the source file or location it was extracted from. This allows for easy |
| 31 | verification and provides context when reviewing the consolidated results. |
| 32 | |
| 33 | ## Core Directives |
| 34 | |
| 35 | When tasked with comprehensive extraction or generation from a large corpus, you |
| 36 | MUST follow this four-phase methodology: |
| 37 | |
| 38 | ### Phase 1: Parallel Expert Discovery |
| 39 | |
| 40 | Never use a single generalist agent or a single prompt to read all files. |
| 41 | |
| 42 | 1. Categorize the input artifacts (e.g., Code/ADK, Diagrams, Test Cases). |
| 43 | 2. Spawn **specialized expert subagents** (e.g., `cxas-ingestor-adk`) in |
| 44 | parallel, providing each with only the context relevant to their expertise. |
| 45 | 3. Consolidate their initial findings into a centralized list. |
| 46 | |
| 47 | ### Phase 2: The Iterative Exhaustion Loop |
| 48 | |
| 49 | LLMs often miss items in a single pass of a large document. You must force them |
| 50 | to iterate. |
| 51 | |
| 52 | 1. Provide the current consolidated list of findings back to the expert |
| 53 | subagents. |
| 54 | 2. Ask a direct question: *"Based on your artifacts, are there ANY MORE items |
| 55 | missing from this list? If yes, list them. If no, reply EXACTLY 'NO'."* |
| 56 | 3. **The Loop Rule:** You MUST continue this loop, updating the consolidated |
| 57 | list each time, until **ALL** expert subagents unanimously reply with "NO". |
| 58 | |
| 59 | ### Phase 3: Logical Clustering |
| 60 | |
| 61 | Once the exhaustive list is finalized (e.g., 100+ subintents), organize it. |
| 62 | |
| 63 | 1. Group the granular findings into high-level logical categories (Parent |
| 64 | CUJs). |
| 65 | 2. Verify with the experts that the parent categories encompass all findings. |
| 66 | |
| 67 | ### Phase 4: Batched Execution & Verification |
| 68 | |
| 69 | Never ask an LLM to generate 100+ complex artifacts (like conversational |
| 70 | transcripts) in a single prompt. It will hallucinate or truncate. |
| 71 | |
| 72 | 1. **Batching:** Divide the exhaustive list into small, manageable batches |
| 73 | (e.g., 10 batches of 10 items). Write these batches to temporary files. |
| 74 | 2. **Delegated Execution:** Spawn a new subagent for *each* batch. Instruct |
| 75 | them to process *only* their assigned batch and write the output to a |
| 76 | specific file. |
| 77 | 3. **The Verification Gate:** As the orchestrator, you MUST verify the output |
| 78 | of each subagent. Did they generate an output for *every single item* in |
| 79 | their batch? |
| 80 | 4. If YES: Accept the batch. |
| 81 | 5. If NO: Discard the output and **respawn** the subagent for that specific |
| 82 | batch with stronger steering instructions. |
| 83 | 6. **Consolidation:** Only when all batches pass the Verification Gate, merge |
| 84 | them into the final, exhaustive deliverable. |