agentleFS
shynlee04shynlee04/hivemind-plugin/skills/context-first-gatekeeping/SKILL.md

context-first-gatekeeping

Skill51 starsChanged 7 months agoMITView on GitHub

The absolute gatekeeping factor for app development success. Context-first, never act without verified planning, unbroken hierarchy chains, and domain boundaries enforced.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check anchors for constraints (list_anchors)

    line 32
  2. Very specific:

    Verify chain integrity (think_back)

    line 33
  3. Distinctive:

    Before ANY implementation action:

    line 141
  4. Distinctive:

    When a gate fails:

    line 162
  5. Distinctive:

    No plan found → Ask user to provide/confirm plan

    line 169
  6. Very specific:

    No trajectory → Must declare_intent (new session)

    line 173

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<EXTREMELY-IMPORTANT> This is the absolute gatekeeping factor. NEVER ACT WITHOUT SUCCESS RETRIEVAL OF PLANNING. Skipping this gatekeeping is the #1 cause of app development failures. </EXTREMELY-IMPORTANT>

Context-First Gatekeeping Skill

The Prime Directive

NEVER ACT WITHOUT SUCCESS RETRIEVAL OF PLANNING

This is the absolute gatekeeping factor that determines whether app development succeeds or fails.

The Five Pillars

Pillar 1: Context-First Protocol

Before ANY action:

  1. Load context (scan_hierarchy)
  2. Recall relevant memories (recall_mems)
  3. Check anchors for constraints (list_anchors)
  4. Verify chain integrity (think_back)

Pattern:

LOAD → VERIFY → ACT

NEVER: Assume, guess, or "I think I remember..."

Pillar 2: Parent Hierarchy Must Exist

Unbroken chain requirement:

Trajectory (Level 1)
└── Tactic (Level 2)
    └── Action (Level 3)

Validation:

function validateHierarchy(): boolean {
  const hierarchy = scan_hierarchy({ action: "status" })
  
  // Level 1: Trajectory must exist
  if (!hierarchy.trajectory) {
    throw new Error("NO TRAJECTORY - Use declare_intent first")
  }
  
  // Level 2: Tactic must exist for actions
  if (!hierarchy.tactic && isActionLevel()) {
    throw new Error("NO TACTIC - Use map_context first")
  }
  
  // Level 3: Chain must be unbroken
  const ancestors = getAncestors()
  if (ancestors.length < requiredLevel) {
    throw new Error("BROKEN CHAIN - Repair with map_context")
  }
  
  return true
}

Pillar 3: Never Act Without Verified Planning

Planning must be retrieved, not assumed:

// WRONG - Acting on assumption
// "I remember we planned to do X, let me implement it"

// RIGHT - Verifying planning exists
const plan = recall_mems({ query: "plan trajectory tactic" })
if (!plan || plan.length === 0) {
  throw new Error("NO PLAN FOUND - Create plan before acting")
}

// THEN act based on verified plan

Pillar 4: Domain Boundaries Enforced

Never cross domains without explicit approval:

DomainAllowed PathsForbidden Paths
Backendsrc/lib/, src/tools/, src/schemas/, src/hooks/src/dashboard/, src/views/
Frontendsrc/dashboard/, src/views/, src/components/src/lib/, src/tools/, src/schemas/
Sharedsrc/types/, src/utils/, tests/None (can cross)

Validation:

function validateDomainBoundary(files: string[], domain: string): boolean {
  const boundaries = DOMAIN_BOUNDARIES[domain]
  
  for (const file of files) {
    const inAllowed = boundaries.allowed.some(p => file.startsWith(p))
    const inForbidden = boundaries.forbidden.some(p => file.startsWith(p))
    
    if (!inAllowed || inForbidden) {
      throw new Error(`DOMAIN VIOLATION: ${file} not in ${domain}`)
    }
  }
  
  return true
}

Pillar 5: Context-Purified State

After context compaction, NEVER trust memory:

// After compaction event
if (justCompacted) {
  // RELOAD everything
  think_back({ mode: "full" })  // Reload context
  recall_mems({ query: "recent" })  // Reload memories
  list_anchors()  // Reload constraints
  
  // VERIFY chain still intact
  validateHierarchy()
}

The Gatekeeping Checklist

Before ANY implementation action:

┌─────────────────────────────────────────────────────────────┐
│                    GATEKEEPING CHECKLIST                     │
├─────────────────────────────────────────────────────────────┤
│  [ ] 1. Trajectory exists?         (declare_intent)         │
│  [ ] 2. Tactic defined?            (map_context)            │
│  [ ] 3. Plan retrieved from mems?  (recall_mems)            │
│  [ ] 4. Anchors loaded?            (list_anchors)           │
│  [ ] 5. Chain unbroken?            (scan_hierarchy)         │
│  [ ] 6. Drift acceptable (<60)?    (think_back)             │
│  [ ] 7. Domain boundaries OK?      (validateDomainBoundary) │
│  [ ] 8. No pending failures?       (brain.metrics.failures) │
└─────────────────────────────────────────────────────────────┘

IF ANY CHECK FAILS → STOP, FIX BEFORE PROCEEDING

Failure Escalation Protocol

When a gate fails:

Level 1: Auto-Recoverable

  • Missing tactic → map_context({ level: "tactic" })
  • High drift → think_back({ mode: "full" })

Level 2: User Guidance Needed

  • No plan found → Ask user to provide/confirm plan
  • Domain violation → Ask user for cross-domain approval

Level 3: Critical - Stop Chain

  • No trajectory → Must declare_intent (new session)
  • Broken chain → Must manually repair hierarchy

Integration with Sequential Orchestration

This skill is the first step in sequential-orchestration:

1. context-first-gatekeeping (THIS SKILL)
   ↓ All gates pass
2. sequential-orchestration
   ↓ Sequential delegation
3. export_cycle
   ↓ Intelligence captured
4. map_context
   ↓ Hierarchy updated

Red Flags - Immediate Stop

Red FlagMeaningRequired Action
"I think..."Assumption, not verifiedSTOP, verify with recall_mems
"Let me just..."Bypassing gatekeepingSTOP, run gatekeeping checklist
"Probably works"No verificationSTOP, run quality gates
"I'll fix later"Leaving broken chainSTOP, fix now before proceeding
"Crossing to other domain"Boundary violationSTOP, get approval or reroute

Quick Commands

# Full gatekeeping check
scan_hierarchy({ action: "status" })  # Check hierarchy
think_back({ mode: "check" })          # Check drift
recall_mems({ query: "plan" })         # Check planning
list_anchors()                        # Check constraints

# Repair broken chain
map_context({ level: "tactic", content: "..." })
map_context({ level: "action", content: "..." })

# Context recovery
think_back({ mode: "full" })

Gatekeeping Flow Diagram

digraph gatekeeping {
    "Action Requested" [shape=doublecircle];
    "Trajectory Exists?" [shape=diamond];
    "Declare Intent" [shape=box];
    "Tactic Defined?" [shape=diamond];
    "Map Context" [shape=box];
    "Plan Retrieved?" [shape=diamond];
    "Recall Mems" [shape=box];
    "Chain Unbroken?" [shape=diamond];
    "Think Back" [shape=box];
    "Drift OK?" [shape=diamond];
    "Domain OK?" [shape=diamond];
    "Get Approval" [shape=box];
    "PROCEED" [shape=doublecircle, style=filled, fillcolor=green];
    "STOP" [shape=doublecircle, style=filled, fillcolor=red];

    "Action Requested" -> "Trajectory Exists?";
    "Trajectory Exists?" -> "Declare Intent" [label="no"];
    "Trajectory Exists?" -> "Tactic Defined?" [label="yes"];
    "Declare Intent" -> "Tactic Defined?";
    "Tactic Defined?" -> "Map Context" [label="no"];
    "Tactic Defined?" -> "Plan Retrieved?" [label="yes"];
    "Map Context" -> "Plan Retrieved?";
    "Plan Retrieved?" -> "Recall Mems" [label="no"];
    "Plan Retrieved?" -> "Chain Unbroken?" [label="yes"];
    "Recall Mems" -> "Chain Unbroken?";
    "Chain Unbroken?" -> "Think Back" [label="no"];
    "Chain Unbroken?" -> "Drift OK?" [label="yes"];
    "Think Back" -> "Drift OK?";
    "Drift OK?" -> "Think Back" [label="no (>60)"];
    "Drift OK?" -> "Domain OK?" [label="yes (<60)"];
    "Domain OK?" -> "Get Approval" [label="no"];
    "Domain OK?" -> "PROCEED" [label="yes"];
    "Get Approval" -> "PROCEED" [label="approved"];
    "Get Approval" -> "STOP" [label="denied"];
}

This skill is a companion to hivemind-governance and must be loaded BEFORE any implementation work begins.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.