Install
openclaw skills install @jose-compu/self-improving-securityCaptures vulnerabilities, misconfigurations, access control violations, compliance gaps, incident response patterns, and threat intelligence to enable continuous security improvement. Use when: (1) A CVE or vulnerability is discovered, (2) Secrets are exposed in logs or output, (3) Access control violations or unauthorized access attempts occur, (4) Compliance audit findings or gaps are identified, (5) Security misconfigurations are found in infrastructure or applications, (6) Incident response procedures are executed or improved, (7) Threat intelligence is gathered from advisories or pen test results.
openclaw skills install @jose-compu/self-improving-securityLog security learnings, incidents, and compliance findings to markdown files for continuous improvement. Security-specific entries track vulnerabilities, misconfigurations, access violations, and incident response outcomes. Mature patterns get promoted to security runbooks, hardening checklists, incident response playbooks, and compliance matrices.
NEVER log actual secrets, credentials, tokens, private keys, API keys, passwords, connection strings, or PII in any learning or incident entry. Always redact sensitive values before writing. Use placeholders:
| Sensitive Data | Redacted Form |
|---|---|
| API keys | REDACTED_API_KEY |
| Passwords | REDACTED_PASSWORD |
| Access tokens (JWT, bearer, session) | REDACTED_TOKEN |
| Private keys | REDACTED_PRIVATE_KEY |
| Connection strings | REDACTED_CONNECTION_STRING |
| PII (emails, SSNs) | REDACTED_PII |
| IP addresses (internal) | REDACTED_INTERNAL_IP |
| Certificate contents | REDACTED_CERT |
When logging an incident involving exposed secrets, describe what kind of secret was exposed, where it appeared, and the remediation taken — never the secret itself.
Before logging anything, ensure the .learnings/ directory and files exist in the project or workspace root. If any are missing, create them:
mkdir -p .learnings
[ -f .learnings/LEARNINGS.md ] || printf "# Security Learnings\n\nVulnerabilities, misconfigurations, compliance gaps, and security insights.\n\n**Categories**: vulnerability | misconfiguration | access_violation | compliance_gap | incident_response | threat_intelligence\n**Areas**: authentication | authorization | encryption | network | endpoint | compliance | cloud\n\n---\n" > .learnings/LEARNINGS.md
[ -f .learnings/SECURITY_INCIDENTS.md ] || printf "# Security Incidents Log\n\nVulnerability discoveries, access violations, secrets exposure, and active security incidents.\n\n---\n" > .learnings/SECURITY_INCIDENTS.md
[ -f .learnings/FEATURE_REQUESTS.md ] || printf "# Security Feature Requests\n\nSecurity capabilities and hardening improvements requested or identified.\n\n---\n" > .learnings/FEATURE_REQUESTS.md
Never overwrite existing files. This is a no-op if .learnings/ is already initialised.
If you want automatic reminders or setup assistance, use the opt-in hook workflow described in Hook Integration.
No credentials or access tokens are required by this skill.
| Situation | Action |
|---|---|
| CVE found in dependency | Log to .learnings/SECURITY_INCIDENTS.md with category vulnerability |
| Secrets exposed in logs/output | Log to .learnings/SECURITY_INCIDENTS.md — REDACT the secret first |
| Access violation or unauthorized access | Log to .learnings/SECURITY_INCIDENTS.md with category access_violation |
| Misconfigured permissions/policies | Log to .learnings/LEARNINGS.md with category misconfiguration |
| Compliance audit failure | Log to .learnings/LEARNINGS.md with category compliance_gap |
| Incident response executed | Log to .learnings/LEARNINGS.md with category incident_response |
| Threat intelligence gathered | Log to .learnings/LEARNINGS.md with category threat_intelligence |
| Security feature needed | Log to .learnings/FEATURE_REQUESTS.md |
| Hardening improvement identified | Log to .learnings/LEARNINGS.md with category misconfiguration |
| SSL/TLS or certificate issue | Log to .learnings/SECURITY_INCIDENTS.md with area encryption |
| CORS misconfiguration | Log to .learnings/LEARNINGS.md with area network |
| Authentication bypass found | Log to .learnings/SECURITY_INCIDENTS.md with area authentication |
| Similar to existing entry | Link with **See Also**, consider priority bump |
| Broadly applicable security pattern | Promote to hardening checklist, runbook, or playbook |
| Proven incident workflow | Promote to AGENTS.md (OpenClaw workspace) |
| Security tool gotcha | Promote to TOOLS.md (OpenClaw workspace) |
| Security principles | Promote to SOUL.md (OpenClaw workspace) |
OpenClaw is the primary platform for this skill. It uses workspace-based prompt injection with automatic skill loading.
Via ClawdHub (recommended):
clawdhub install self-improving-security
Manual:
git clone https://github.com/jose-compu/self-improving-security.git ~/.openclaw/skills/self-improving-security
OpenClaw injects these files into every session:
~/.openclaw/workspace/
├── AGENTS.md # Incident response workflows, delegation patterns
├── SOUL.md # Security principles, assume-breach mindset
├── TOOLS.md # Security tool capabilities, scanner configs
├── MEMORY.md # Long-term memory (main session only)
├── memory/ # Daily memory files
│ └── YYYY-MM-DD.md
└── .learnings/ # This skill's log files
├── LEARNINGS.md
├── SECURITY_INCIDENTS.md
└── FEATURE_REQUESTS.md
mkdir -p ~/.openclaw/workspace/.learnings
Then create the log files (or copy from assets/):
LEARNINGS.md — misconfigurations, compliance gaps, threat intelligence, best practicesSECURITY_INCIDENTS.md — vulnerabilities, access violations, secrets exposureFEATURE_REQUESTS.md — security capabilities and hardening requestsWhen security learnings prove broadly applicable, promote them:
| Learning Type | Promote To | Example |
|---|---|---|
| Security principles | SOUL.md | "Assume breach, defense in depth" |
| Incident response workflows | AGENTS.md | "Rotate credentials before root cause analysis" |
| Security tool hardening | TOOLS.md | "Always pass --no-cache to docker build in CI" |
| Hardening checklist items | HARDENING.md | "Disable directory listing on all web servers" |
| Incident response steps | PLAYBOOKS.md | "Secrets exposure containment procedure" |
| Compliance requirements | COMPLIANCE.md | "GDPR data retention audit quarterly" |
For automatic reminders at session start:
cp -r hooks/openclaw ~/.openclaw/hooks/self-improving-security
openclaw hooks enable self-improving-security
See references/openclaw-integration.md for complete details.
For Claude Code, Codex, Copilot, or other agents, create .learnings/ in the project or workspace root:
mkdir -p .learnings
Create the files inline using the headers shown above. Avoid reading templates from the current repo or workspace unless you explicitly trust that path.
Add to AGENTS.md, CLAUDE.md, or .github/copilot-instructions.md:
When security issues or findings occur:
.learnings/SECURITY_INCIDENTS.md, LEARNINGS.md, or FEATURE_REQUESTS.mdCLAUDE.md - security conventions and constraintsAGENTS.md - incident response workflows.github/copilot-instructions.md - security context for CopilotAppend to .learnings/LEARNINGS.md:
## [LRN-YYYYMMDD-XXX] category
**Logged**: ISO-8601 timestamp
**Priority**: low | medium | high | critical
**Status**: pending
**Area**: authentication | authorization | encryption | network | endpoint | compliance | cloud
**CVSS**: N/A or score (e.g., 7.5)
### Summary
One-line description of the security finding or learning
### Details
Full context: what was found, the security impact, affected systems, root cause
### Remediation
Specific fix, hardening step, or compensating control
### Metadata
- Source: cve_advisory | pen_test | audit | user_feedback | incident | scan
- Related Files: path/to/file.ext
- Tags: tag1, tag2
- CVE: CVE-YYYY-NNNNN (if applicable)
- CWE: CWE-XXX (if applicable)
- See Also: LRN-20250110-001 (if related to existing entry)
- Pattern-Key: harden.input_validation | comply.gdpr_consent (optional)
- Recurrence-Count: 1 (optional)
- First-Seen: 2025-01-15 (optional)
- Last-Seen: 2025-01-15 (optional)
---
Append to .learnings/SECURITY_INCIDENTS.md:
## [SEC-YYYYMMDD-XXX] incident_type
**Logged**: ISO-8601 timestamp
**Priority**: critical | high | medium | low
**Status**: pending
**Area**: authentication | authorization | encryption | network | endpoint | compliance | cloud
**Severity**: critical | high | medium | low
**CVSS**: score or N/A
### Summary
Brief description of the security incident
### Incident Details
Sanitized error output, log excerpt, or finding description. NEVER include actual secrets, tokens, keys, or PII here.
### Impact Assessment
- Affected systems/services
- Data at risk (type, not content)
- Blast radius estimate
### Containment & Remediation
- Immediate containment steps taken
- Root cause (if known)
- Long-term remediation plan
### Timeline
- **Detected**: ISO-8601
- **Contained**: ISO-8601 (if applicable)
- **Resolved**: ISO-8601 (if applicable)
### Metadata
- CVE: CVE-YYYY-NNNNN (if applicable)
- CWE: CWE-XXX (if applicable)
- Attack Vector: network | adjacent | local | physical
- Reproducible: yes | no | unknown
- Related Files: path/to/file.ext
- See Also: SEC-20250110-001 (if related)
---
Append to .learnings/FEATURE_REQUESTS.md:
## [FEAT-YYYYMMDD-XXX] capability_name
**Logged**: ISO-8601 timestamp
**Priority**: medium
**Status**: pending
**Area**: authentication | authorization | encryption | network | endpoint | compliance | cloud
### Requested Capability
What security capability is needed
### Security Justification
Why this capability matters — what risk it mitigates, what compliance requirement it satisfies
### Complexity Estimate
simple | medium | complex
### Suggested Implementation
How this could be built, what security controls it enables
### Metadata
- Frequency: first_time | recurring
- Related Features: existing_feature_name
- Compliance: SOC2 | GDPR | HIPAA | PCI-DSS | ISO27001 (if applicable)
---
Format: TYPE-YYYYMMDD-XXX
LRN (learning), SEC (security incident), FEAT (feature request)001, A7B)Examples: LRN-20250415-001, SEC-20250415-A3F, FEAT-20250415-002
When an issue is fixed or mitigated, update the entry:
**Status**: pending → **Status**: resolved### Resolution
- **Resolved**: 2025-01-16T09:00:00Z
- **Commit/PR**: abc123 or #42
- **Remediation Applied**: Brief description of fix or compensating control
- **Verified By**: pen test | scan | manual review
Other status values:
in_progress - Actively being investigated or remediatedwont_fix - Risk accepted (add justification in Resolution notes)promoted - Elevated to hardening checklist, runbook, or playbookpromoted_to_skill - Extracted as a reusable skillWhen a finding is broadly applicable, promote it to permanent security documentation.
| Target | What Belongs There |
|---|---|
CLAUDE.md | Security constraints, banned patterns, safe defaults |
AGENTS.md | Incident response workflows, security scan automation |
.github/copilot-instructions.md | Security coding standards for Copilot |
SOUL.md | Security mindset: assume breach, defense in depth, least privilege |
TOOLS.md | Security scanner configs, tool-specific hardening |
HARDENING.md | Infrastructure and application hardening checklist |
PLAYBOOKS.md | Incident response playbooks |
COMPLIANCE.md | Compliance matrices and audit evidence |
**Status**: pending → **Status**: promoted**Promoted**: HARDENING.md (or whichever target)If logging something similar to an existing entry:
grep -r "keyword" .learnings/**See Also**: SEC-20250110-001 in MetadataAutomatically log when you notice:
Vulnerability Indicators (→ security incident):
CVE- prefix in output or advisoriesCRITICAL or HIGH severity in scan resultsvulnerability or exploit in dependency audit outputSecrets Exposure (→ security incident, REDACT IMMEDIATELY):
.env files with secrets committed to gitAccess Control Issues (→ security incident):
Permission denied in unexpected contexts403 Forbidden or 401 Unauthorized errorsInfrastructure Signals (→ learning):
SSL or TLS handshake failurescertificate expired or certificate verify failedCORS policy violations or misconfigurationsinsecure flag usage in tools or configsCompliance Signals (→ learning):
Feature Requests (→ feature request):
| Priority | When to Use |
|---|---|
critical | Active exploitation, data breach, secrets exposed in production, zero-day |
high | Known CVE unpatched, secrets in CI/CD logs, missing auth on public endpoint |
medium | Misconfiguration with compensating controls, compliance gap with workaround |
low | Hardening improvement, defense-in-depth enhancement, informational finding |
Use to filter findings by security domain:
| Area | Scope |
|---|---|
authentication | Login, MFA, session management, credential storage |
authorization | RBAC, ABAC, permission models, access policies |
encryption | TLS/SSL, at-rest encryption, key management, certificates |
network | Firewalls, CORS, DNS, load balancers, ingress/egress |
endpoint | API security, input validation, rate limiting, WAF |
compliance | SOC2, GDPR, HIPAA, PCI-DSS, ISO 27001, audit trails |
cloud | IAM policies, S3 buckets, security groups, KMS, cloud posture |
Review .learnings/ at natural breakpoints:
# Count pending security items
grep -h "Status\*\*: pending" .learnings/*.md | wc -l
# List pending critical/high items
grep -B5 "Priority\*\*: critical\|Priority\*\*: high" .learnings/*.md | grep "^## \["
# Find findings for a specific area
grep -l "Area\*\*: authentication" .learnings/*.md
# List all CVEs referenced
grep -h "CVE:" .learnings/*.md | sort -u
Enable automatic reminders through agent hooks. This is opt-in.
UserPromptSubmit with scripts/activator.sh only.PostToolUse (scripts/error-detector.sh) only in trusted environments when you explicitly want command-output pattern checks.Create .claude/settings.json in your project:
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improving-security/scripts/activator.sh"
}]
}]
}
}
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improving-security/scripts/activator.sh"
}]
}],
"PostToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "./skills/self-improving-security/scripts/error-detector.sh"
}]
}]
}
}
| Script | Hook Type | Purpose |
|---|---|---|
scripts/activator.sh | UserPromptSubmit | Reminds to evaluate security findings |
scripts/error-detector.sh | PostToolUse (Bash) | Detects security-relevant patterns in output |
See references/hooks-setup.md for detailed configuration and troubleshooting.
When a security learning is valuable enough to become a reusable skill, extract it.
| Criterion | Description |
|---|---|
| Recurring | Has See Also links to 2+ similar findings |
| Verified | Status is resolved with confirmed remediation |
| Non-obvious | Required investigation or specialized knowledge |
| Broadly applicable | Not environment-specific; useful across projects |
| User-flagged | User says "save this as a security skill" |
./skills/self-improving-security/scripts/extract-skill.sh skill-name --dry-run
./skills/self-improving-security/scripts/extract-skill.sh skill-name
promoted_to_skill, add Skill-PathIn conversation:
In entries:
See Also links (recurring vulnerability pattern)incident_response with documented procedureKeep learnings local (recommended for security):
.learnings/
Security findings may contain sensitive context. Default to local-only.
Track learnings in repo (team-wide, sanitized): Only if all entries are confirmed free of secrets, credentials, and PII.
Activation: Hooks (UserPromptSubmit, PostToolUse)
Setup: .claude/settings.json with hook configuration
Detection: Automatic via hook scripts
Activation: Hooks (same pattern as Claude Code)
Setup: .codex/settings.json with hook configuration
Activation: Manual (no hook support)
Setup: Add security self-improvement guidance to .github/copilot-instructions.md
Activation: Workspace injection + inter-agent messaging Setup: See "OpenClaw Setup" section above
Regardless of agent, apply security self-improvement when you:
This skill is standalone-compatible and stackable with other self-improving skills.
.learnings/security/.learnings/INDEX.mdEvery new entry must include:
**Skill**: security
event + matcher + file + 5m_window; max 1 reminder per skill every 5 minutes.Only trigger this skill automatically for security signals such as:
cve-|vulnerability|exploit|secret|token|credential|key leakedauth bypass|privilege escalation|tls|ssl|cors misconfigurationWhen guidance conflicts, apply:
securityengineeringcodingaimeta as tie-breaker.learnings/security/ in stackable mode.