Gap analysis pattern

From CarlosCaPe/octorato · View interactive version

Gap analysis pattern is an AI agent skill from the GitHub repository CarlosCaPe/octorato. Gap Analysis Pattern

How to use this skill

Skill file

Gap Analysis Pattern

What

A pre-flight check that compares the desired state against the **current

state** of the database, reporting exactly what changes are needed before any

modifications are made.

Why

Gap analysis answers three questions before any work begins:

  1. What needs to be done? (changes pending)
  2. What's already done? (idempotent re-runs)
  3. What's unexpected? (anomalies that need investigation)

This information is logged as NOTICE messages, creating an audit trail of the

database state at the moment the script runs.

How

-- Column gap analysis
IF EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = 'public'
      AND table_name = 'Applicant'
      AND column_name = 'SpeialtyRequirement'  -- old name
) THEN
    RAISE NOTICE '  [--] COL 1 SpeialtyRequirement -> SpecialtyRequirement -- NEEDS RENAME';
    v_old_found := v_old_found + 1;
ELSIF EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = 'public'
      AND table_name = 'Applicant'
      AND column_name = 'SpecialtyRequirement'  -- new name
) THEN
    RAISE NOTICE '  [OK] COL 1 SpecialtyRequirement -- ALREADY RENAMED';
    v_new_found := v_new_found + 1;
ELSE
    RAISE NOTICE '  [!!] COL 1 Neither old nor new column found -- UNEXPECTED';
END IF;

The three-state pattern

| Marker | Meaning | Action |

|--------|---------|--------|

| [--] | Change needed | Will be applied in Phase 2 |

| [OK] | Already done | Skip (idempotent) |

| [!!] | Unexpected state | Investigate before proceeding |

When to Use

Where We Used It

Gotchas

the totals -- this makes log review much faster

abort -- sometimes the unexpected state is a valid edge case


Category: Architecture | Origin: All tickets

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.