Security compliance is one of those things every business knows they need — and almost nobody enjoys doing. CIS benchmarks alone have hundreds of controls. Trivy scans generate walls of CVEs. And someone has to actually fix all that stuff.

We decided to let AI do the heavy lifting.

Over the past two weeks, we built an AI-driven security hardening platform that integrates 25+ open-source security tools, orchestrated entirely through Claude Code. It runs CIS compliance audits, vulnerability scans, rootkit detection, and — this is the part that matters — automated remediation.

Here's how it works, with real code from our production system.

The Architecture: Wrappers Beat MCP (By a Lot)

When we started, the obvious choice was Anthropic's Model Context Protocol (MCP). It's the standard way to give AI agents access to tools. But we ran the numbers and made a different call.

MCP overhead: ~18,000 tokens per session just to load tool definitions.
Our wrapper approach: ~500 tokens per session.
That's a 95–97% reduction in token cost.

The wrapper architecture is dead simple. Each security tool gets a Bash script that:

  1. Validates inputs
  2. Runs the tool
  3. Parses output into structured JSON
  4. Returns results Claude can act on

Here's our Lynis audit wrapper — the real code from production:

#!/bin/bash
# Lynis Security Audit Wrapper
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../bash/common.sh"
source "$SCRIPT_DIR/../bash/logging.sh"
source "$SCRIPT_DIR/../bash/json.sh"

PROFILE="${1:-default}"
log_info "Starting Lynis audit with profile: $PROFILE"
check_tool "lynis" "lynis"
require_root

TIMESTAMP="$(get_timestamp)"
LOG_FILE="$PROJECT_ROOT/data/state/scans/lynis-$TIMESTAMP.log"

if lynis audit system --quick --no-colors --logfile "$LOG_FILE" > /dev/null 2>&1; then
    HARDENING_INDEX=$(grep "Hardening index" /var/log/lynis.log \
      | awk -F'[' '{print $2}' | awk -F']' '{print $1}')
    WARNINGS=$(grep -c "^warning\[" /var/log/lynis.log || echo "0")
    SUGGESTIONS=$(grep -c "^suggestion\[" /var/log/lynis.log || echo "0")
fi

No SDK. No persistent process. No protocol handshake. Just a script that runs a tool and returns JSON. Claude Code calls it like any shell command.

Security Hardening Architecture — Claude Code orchestrating 9 wrapper scripts connected to security tools

The Nine Wrappers: Complete Security Coverage

Each wrapper follows the same pattern — validate, execute, parse, return. Here's what we cover:

WrapperToolWhat It Does
lynis-audit.shLynisCIS compliance auditing, hardening score
trivy-scan-fs.shTrivyFilesystem vulnerability scanning
rkhunter-scan.shrkhunterRootkit and backdoor detection
osquery-run.shosquerySQL-based system introspection
aide-check.shAIDEFile integrity monitoring
fail2ban-status.shFail2BanIntrusion prevention status
auditd-search.pyauditdKernel audit log analysis
osv-scan.shOSV ScannerOpen Source Vulnerability detection
suricata-alerts.pySuricataNetwork IDS alert parsing

Total codebase: ~2,500 lines. An MCP implementation would have been 10,000+. Less code means fewer bugs, faster iteration, and easier maintenance.

Automated CIS Compliance: The Hardening Playbook

The CIS Ubuntu Level 1 benchmark is the gold standard for server hardening. Our playbook automates the entire thing. Here's the core pattern — each control follows the same apply_fix structure:

#!/bin/bash
# CIS Ubuntu Level 1 - Automated Hardening
set -euo pipefail

FIXES_APPLIED=0
FIXES_FAILED=0
FIXES_SKIPPED=0

apply_fix() {
    local cis_id="$1"
    local severity="$2"
    local description="$3"
    local check_cmd="$4"
    local fix_cmd="$5"
    local backup_files="${6:-}"

    log_action "[$severity] CIS $cis_id: $description"

    # Check if already compliant
    if eval "$check_cmd" &>/dev/null; then
        log_info "✓ Already compliant"
        return 0
    fi

    # Backup files before modifying
    if [[ -n "$backup_files" ]]; then
        for file in $backup_files; do
            cp "$file" "$BACKUP_DIR/" 2>/dev/null || true
        done
    fi

    # Apply the fix
    if eval "$fix_cmd" &>/dev/null; then
        log_success "✓ Fixed"
        ((FIXES_APPLIED++))
    else
        log_error "✗ Failed"
        ((FIXES_FAILED++))
    fi
}

Notice what this does: check first, backup, then fix. Every change is reversible. Every result is logged. This isn't "hope for the best" automation — it's production-grade compliance.

The playbook covers the full CIS Level 1 scope: filesystem configuration, service hardening, network parameters, access control, logging, and audit configuration.

The Auto-Remediation Engine

Scanning finds problems. But finding problems is the easy part — fixing them is where most teams stall. Our auto-remediation engine bridges that gap.

It reads scan results, classifies vulnerabilities by severity (P0 Critical through P3 Low), and applies fixes automatically where safe:

remediate() {
    local severity="$1"
    local cve_id="$2"
    local package="$3"
    local description="$4"
    local fix_type="$5"

    ((TOTAL_ISSUES++))
    log_action "[$severity] $cve_id - $package: $description"

    case "$fix_type" in
        "apt-upgrade")
            if sudo DEBIAN_FRONTEND=noninteractive apt-get install \
                --only-upgrade -y "$package" &>>"$REPORT_FILE"; then
                log_success "✓ $package upgraded successfully"
                ((REMEDIATED++))
            else
                log_error "✗ Failed to upgrade $package"
                ((FAILED++))
            fi
            ;;
        "remove-package")
            if dpkg -l "$package" 2>/dev/null | grep -q "^ii"; then
                sudo apt-get purge -y "$package" &>>"$REPORT_FILE"
                ((REMEDIATED++))
            fi
            ;;
        "manual")
            log_warn "Requires manual review"
            ((MANUAL_REVIEW++))
            ;;
    esac
}
Automated remediation flow — scan, classify, fix, verify cycle

The key design decision: not everything gets auto-fixed. Package upgrades and standard config changes run automatically. Anything that could break services gets flagged for manual review. This is the difference between useful automation and dangerous automation.

Why This Matters for Your Business

Here's the thing about security compliance in 2026: agentic AI is both the threat and the solution.

According to Dark Reading, agentic AI is becoming "the attack-surface poster child" this year. AI enables attackers to launch wider-scale attacks to find vulnerabilities. Forbes predicts enterprises will need AI firewalls, secure-by-design architectures, and agent governance frameworks.

The businesses that survive aren't the ones with the biggest security teams. They're the ones who automated the boring parts — the routine scans, the package updates, the compliance checks — so their humans can focus on the hard stuff.

Our platform handles the full cycle:

  1. Scan — Nine wrappers cover vulnerabilities, compliance, integrity, and intrusion detection
  2. Classify — Automated severity ranking from P0 to P3
  3. Fix — Auto-remediation for safe fixes, flagging for risky ones
  4. Verify — Re-scan after fixes to confirm compliance
  5. Report — Timestamped logs for audit trails

And because it's all orchestrated through Claude Code, you can ask it questions in plain English: "What's our current hardening score?" or "Are there any critical CVEs in our dependencies?"

The Numbers

After two weeks of building:

Getting Started

You don't need our exact setup to benefit from this approach. The pattern is universal:

  1. Pick your security tools — Lynis, Trivy, and Fail2Ban cover 80% of what most businesses need
  2. Write thin wrappers — Bash scripts that run tools and return JSON. Keep them under 200 lines each
  3. Let AI orchestrate — Point Claude Code (or your preferred AI agent) at the wrappers
  4. Automate remediation carefully — Auto-fix the safe stuff, flag the rest
  5. Run on a schedule — Weekly scans, daily for production systems

The entire platform is open source, built with nothing but Bash, Python, and standard Linux tools. No paid dependencies. No vendor lock-in. Just tools that work.


Security hardening doesn't have to be a quarterly fire drill. With the right automation, it becomes background infrastructure — always running, always watching, always fixing. That's the future we're building.

Want to see how AI-driven automation can transform your security posture? Get in touch — we'll show you what's possible.

🔒
FREE

CIS Compliance Checklist

The exact 10-step checklist we use to harden AI systems against CIS benchmarks.
No spam. Unsubscribe anytime.