API Security Hardening
This loop identifies and remediates insecure API patterns and vulnerabilities in Node.js projects by iteratively running npm audit and applying security fixes until the codebase passes security scanning.
Goal
Remove insecure API patterns
How to Run
Automatically hardens API security by scanning dependencies, identifying vulnerabilities, and applying safe fixes.
- 01
Initiate the Loop
Start the loop in your preferred coding environment (Cursor, Claude Code, etc.)
- 02
Automated Scanning & Fixing
The agent will run 'npm audit', analyze vulnerabilities, and apply fixes using 'npm audit fix' or manual remediation
- 03
Iterative Validation
After each fix iteration, re-run 'npm audit' until no vulnerabilities remain
Workflow Steps
- 01
Initial Security Assessment
Run 'npm audit' to identify all existing vulnerabilities in project dependencies
- 02
Vulnerabilities Analysis
Parse audit results to categorize issues by severity and impact on API security
- 03
Apply Automated Fixes
Execute 'npm audit fix' for safe updates, then manually address remaining critical issues
- 04
Codebase Verification
Ensure all security patches maintain API functionality and don't introduce breaking changes
- 05
Re-scan and Iterate
Re-run 'npm audit' to validate fixes; repeat process if vulnerabilities persist
Kickoff Prompt
Start the "API Security Hardening" loop. Goal: Remove insecure API patterns Max iterations: 10 Between iterations run: npm audit Exit when: Security scan passes Start API Security Hardening loop. Begin by running 'npm audit' to identify vulnerabilities, then apply fixes using 'npm audit fix' and manual remediation. Continue iterating until the security scan passes with no vulnerabilities. Self-pace this loop. After each iteration, run `npm audit` and evaluate the output, and only continue if the exit condition is not met (Security scan passes). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.
Guardrails
hardcoded- ·Only modify package.json and lock files when applying automated fixes
- ·Never expose sensitive environment variables or credentials
- ·Create backups before major dependency updates
- ·Prioritize high-severity vulnerabilities first
- ·Avoid breaking changes to API contracts without explicit approval
Flow Diagram
Related loops — API
API
Resolve API Error Responses
This loop standardizes API error responses across the application to improve client-side error handling and debugging. It ensures all error responses follow a consistent structure (e.g., RFC 7807 Problem Details format) with appropriate HTTP status codes and machine-readable error codes.
API
Fix Failing Integration Endpoints
Automatically detects and resolves issues in failing API integration endpoints through iterative testing and code modifications.
API
API Performance Budget
A coding loop focused on optimizing API performance to ensure P95 latency stays under a defined target threshold. This loop iteratively runs load tests, analyzes bottlenecks, and implements optimizations until the goal is achieved or maximum iterations are reached.