Validate and Filter All External Input at System Boundaries
A four-phase protocol that forces every external data entry point through classification and mandatory validation before any code touches it.
Maintainer of this project? Claim this page to edit the listing.
13.5.0Add to Favorites
Why it matters
Prevent security vulnerabilities, crashes, and silent bugs by enforcing mandatory validation filters on every piece of external data before it reaches your application logic, storage, or rendering layer.
Outcomes
What it gets done
Detect and map every entry point where external data enters the system (APIs, user input, env vars, file reads)
Classify each input by trust level and determine which require validation filters
Generate validation code with type checking, schema validation, sanitization, and explicit rejection on bad input
Verify no unfiltered untrusted data reaches business logic by tracing each entry point through the codebase
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-infinity | bash Overview
infinity - Input Boundary & Validation Protocol
A four-phase input validation protocol that lists, classifies by trust level, filters, and verifies every external data entry point before code is considered complete. Use whenever code handles an API response, user input, env vars, webhooks, file reads, or CLI arguments - not for purely internal logic.
What it does
Infinity enforces one core rule: nothing untrusted ever reaches the core of an application - it is stopped before contact. It works through four phases in strict order: first listing every entry point in scope (HTTP bodies/headers/query params, form inputs, env vars, third-party API responses, webhook payloads, file reads, CLI args, WebSocket messages) before writing any handling code at all; then classifying each one as TRUSTED (internal constants, hardcoded config), SEMI-TRUSTED (internal services, your own database reads), or UNTRUSTED (anything from users, the internet, third parties, or the filesystem); then writing a mandatory filter layer for every SEMI-TRUSTED/UNTRUSTED input; and finally tracing every entry point to confirm a filter genuinely exists before declaring the work done.
When to use - and when NOT to
Use it when handling an API response, reading user input or a form submission, working with environment variables or CLI arguments, parsing a webhook, reading from the filesystem, or writing any code that touches .body, .params, .query, .env, fs.read, or a third-party SDK response. It explicitly does not apply to purely internal logic with no external data involved, and the skill itself notes it may add unwarranted verbosity to trivial scripts where strict validation isn't actually needed.
Inputs and outputs
Phases 1, 2, and 4 produce no code, only structured output: a "BOUNDARY MAP" table classifying each entry point's trust level and whether a filter is required, and a later "VERIFICATION" table confirming a filter exists for each one, explicitly stating "Unfiltered inputs reaching logic: NONE" or flagging any gap. Phase 3 is where code gets written, covering type checking (never assume a string is a string), schema validation (reject on a missing required field rather than falling back silently), sanitization before rendering to prevent XSS, and presence/format checks for env vars, IDs, and tokens. Its hard rules are absolute: no raw external data in business logic ever, no silent fallbacks on bad input, no assuming shape even when an API "always" returns the same thing, missing env vars must fail loudly at startup rather than silently at runtime, and a filter that only checks presence but not format doesn't count as filtered.
INFINITY - BOUNDARY MAP
req.body.email | UNTRUSTED | format + sanitize
PAGINATION_LIMIT=20 | TRUSTED | none needed
Integrations
It is a process discipline rather than a library dependency, applying wherever code reads req.body/req.params/req.query, process.env, filesystem reads, webhook payloads, or third-party API/SDK responses, regardless of language or framework.
Who it's for
Developers writing any code that touches external input - API handlers, form processing, webhook receivers, CLI tools, or file readers - who want a systematic way to prevent the class of bugs the skill names explicitly: SQL injection from unvalidated params, crashes from unexpected API response shapes, XSS from unescaped content, and silent failures from missing environment variables discovered only at runtime.
Source README
infinity - Input Boundary & Validation Protocol
Core Philosophy
Nothing untrusted ever reaches the core - it is stopped before contact. No external data touches the codebase raw. Every boundary where data enters the system must have a filter.
The #1 source of silent bugs, crashes, and vulnerabilities is external data that arrives in an unexpected shape and gets used directly without checking. This skill enforces a filter layer at every entry point, every time.
When to Use This Skill
- Use when you need to handle an API response
- Use when reading user input or adding a form handler
- Use when working with environment variables or CLI arguments
- Use when parsing webhooks or reading from the filesystem
- Use when any code calls
.body,.params,.query,.env,fs.read, or a third-party SDK response
The Four Phases
PHASE 1 - Boundary Detection
Before writing or modifying any code that involves external data, the AI must identify and list every entry point in scope:
- HTTP request bodies, headers, query params
- User form inputs and UI-submitted data
- Environment variables and config files
- Third-party API responses
- Webhook payloads
- File reads from disk
- CLI arguments
- Database query results from external sources
- WebSocket messages
The AI must not write any data-handling logic until every entry point in scope is listed.
PHASE 2 - Classify Each Input
For every entry point identified, the AI classifies it into one of three trust levels:
| Level | Definition | Examples |
|---|---|---|
TRUSTED |
Internal constants, hardcoded values, your own compile-time config | Enum values, hardcoded defaults, internal constants |
SEMI-TRUSTED |
Your own internal services, internal APIs, controlled infrastructure | Internal microservice responses, your own database reads |
UNTRUSTED |
Anything from users, the internet, third parties, or the filesystem | User input, external API responses, uploaded files, env vars, CLI args |
Rule:
TRUSTEDinputs may be used directly.SEMI-TRUSTEDandUNTRUSTEDinputs must pass through a filter layer before any use.
The AI outputs this classification before writing any handling code:
INFINITY — BOUNDARY MAP
─────────────────────────────────────────
Entry Point | Trust Level | Filter Required
─────────────────────────────────────────
req.body.email | UNTRUSTED | ✓ format + sanitize
process.env.API_KEY | UNTRUSTED | ✓ presence + non-empty
internalService.getData()| SEMI-TRUSTED | ✓ schema validate
PAGINATION_LIMIT = 20 | TRUSTED | ✗ none needed
─────────────────────────────────────────
PHASE 3 - Mandatory Filter Layer
Every UNTRUSTED and SEMI-TRUSTED input must pass through validation before it reaches any business logic, storage, or rendering. The AI must apply the right filter type for the right context:
Type Checking
- Verify the input is the expected type before using it
- Never assume a string is a string, a number is a number, or an array is an array
Schema Validation
- For objects and API responses, validate shape before accessing nested fields
- If a required field is missing, reject - do not use a fallback that hides the problem
Sanitization
- Strip or escape content before rendering to UI (prevent XSS)
- Normalize strings before storage (trim whitespace, consistent casing where appropriate)
Presence & Format Checks
- Env vars: must exist and be non-empty before use
- IDs and tokens: must match expected format before use
Rejection Rule
- On invalid input: reject explicitly and return a clear error
- Never silently use bad data with a fallback
- Never let bad data pass through to fix itself "downstream"
// WRONG — using raw input directly
const user = await db.find(req.params.id);
// RIGHT — validate before use
const id = req.params.id;
if (!id || typeof id !== 'string' || !isValidUUID(id)) {
return res.status(400).json({ error: 'Invalid ID format' });
}
const user = await db.find(id);
PHASE 4 - Self-Check Before Done
Before the AI declares any data-handling code complete, it traces each entry point and confirms:
INFINITY — VERIFICATION
─────────────────────────────────────────
Entry Point | Filter Exists | Filter Type
─────────────────────────────────────────
req.body.email | ✓ YES | format + sanitize
process.env.API_KEY | ✓ YES | presence check
internalService.getData()| ✓ YES | schema validation
─────────────────────────────────────────
Unfiltered inputs reaching logic: NONE ✓
─────────────────────────────────────────
If any UNTRUSTED or SEMI-TRUSTED input reaches logic, storage, or rendering without a filter - the AI flags it. It does not silently pass.
Hard Rules (Never Violated)
- No raw external data in business logic. Ever.
- No silent fallbacks on bad input. Reject explicitly.
- No assuming shape. Even if the API "always" returns a string - validate it.
- No skipping env var checks. Missing env vars must fail loudly at startup, not silently at runtime.
- No partial filtering. If you validate presence but not format, it is not filtered.
- No filtering in the wrong place. Filters go at the entry point - not somewhere downstream after the data has already been used once.
What This Skill Prevents
- SQL injection via unvalidated query params
- Crashes from unexpected API response shapes
- XSS from unescaped user content rendered to UI
- Silent failures from missing env variables discovered at runtime
- Type errors from assuming external data matches expected shape
- Security vulnerabilities from untrusted data reaching sensitive operations
Quick Reference
| Phase | Action | Writes Code? |
|---|---|---|
| 1 - Detect | List all entry points in scope | ❌ No |
| 2 - Classify | Assign trust level to each input | ❌ No |
| 3 - Filter | Write filter layer for all UNTRUSTED + SEMI-TRUSTED | ✅ Yes |
| 4 - Verify | Trace each input, confirm filter exists | ❌ No |
Limitations
- Does not apply to purely internal logic with no external data involvement.
- May add verbosity to trivial scripts where strict validation is not required.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.