maximus-ai-safety-governance
Skill1 starsChanged 4 months agoMITView on GitHub
Responsible-AI controls in production: PII redaction, prompt-injection defense, output filtering, immutable audit logs, model cards, bias evals, EU AI Act and NIST AI RMF. Use for 'prompt injection defense', 'PII redaction', 'AI audit log', 'model card', 'AI governance'.
In this repository49 other files it gives its agents.
- core/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- file-opsSkill
- maximus-agent-designSkill
- maximus-ai-cost-controlSkill
- maximus-ai-data-pipelineSkill
- maximus-ai-fluency-for-buildersSkill
- maximus-ai-product-specSkill
- maximus-ai-ux-patternsSkill
- maximus-brainSkill
- maximus-build-featureSkill
- maximus-chain-of-verificationSkill
- maximus-code-reviewSkill
- maximus-contact-intelligenceSkill
- maximus-counterparty-discoverySkill
- maximus-debug-incidentSkill
- maximus-deep-research-proSkill
- maximus-deep-researchSkill
- maximus-design-specSkill
- maximus-devops-shipSkill
- maximus-eval-and-testSkill
- maximus-fine-tuningSkill
- maximus-fintech-paymentsSkill
- maximus-investigative-researchSkill
- maximus-k3-model-selectionSkill
- maximus-k3-self-hostingSkill
- maximus-literature-reviewSkill
- maximus-llm-model-selectionSkill
- maximus-local-research-assistantSkill
- maximus-local-research-assistantSkill
- maximus-mlops-deploySkill
- maximus-ollama-opsSkill
- maximus-openclaw-localSkill
- maximus-people-finder-recruiterSkill
- maximus-people-finderSkill
- maximus-plan-implementationSkill
- maximus-prompt-engineeringSkill
- maximus-python-scientificSkill
- maximus-rag-pipelineSkill
- maximus-replit-handoff-proSkill
- maximus-slm-evalSkill
- maximus-slm-local-finetuneSkill
- maximus-slm-local-stackSkill
- maximus-slm-tool-callingSkill
- maximus-transaction-analystSkill
- maximus-write-articleSkill
- memory-keeperSkill
- skill-templateSkill
- web-researchSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
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
- Distinctive: line 22
Defense in depth: No single control is sufficient.
- Very specific: line 35
Use references/eu-ai-act-risk-tiers.md for the full mapping.
- Distinctive: line 48
Keep a list of PII categories in scope (names, emails, SSN, credit card, health identifiers).
- Very specific: line 53
Use delimiters (<user_input>...</user_input>) to clearly bound user-controlled text.
- Distinctive: line 66
Use an append-only store (S3 with Object Lock, a write-only database table, or a SIEM).
- Distinctive: line 75
Use a structured evaluation set that includes demographic parity slices (by inferred gender, ethnicity, age group — in the prompts, not …
- Distinctive: line 78
Document results in the model card.
- Very specific: line 80
Cross-reference the product spec: Every safety control maps to a refusal or failure mode defined in maximus-ai-product-spec.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
Maximus — AI Safety & Governance
Safety is not a checklist you add after shipping. It's the load-bearing wall of the feature. This skill covers the practical controls — PII handling, injection defense, output filtering, audit logging, bias evaluation, and regulatory mapping — that keep AI features in production and out of the news.
When to use
- Building any user-facing AI feature that processes user input or produces user-visible output.
- Auditing an existing AI feature for compliance with EU AI Act or NIST AI RMF.
- Writing a model card for an internally trained or externally sourced model.
- Investigating a safety incident (unexpected output, PII leak, prompt injection success).
Core rules
- Defense in depth. No single control is sufficient. Layer PII detection, input sanitization, output filtering, and logging. One layer failing should not cause a breach.
- Audit logs are immutable. Log every model call: inputs (after PII scrub), outputs, model version, latency, user ID hash. Write-only store. No delete path.
- Refusal is not censorship. Define refusal categories in the spec (
maximus-ai-product-spec) before implementing them here. A refusal without a defined category is an untestable control. - Regulatory tier first. Determine the EU AI Act and NIST AI RMF tier before building. High-risk features have different control requirements than minimal-risk ones.
- Model cards ship with models. A deployed model without a model card is an unverified asset.
Procedure
- Classify the feature under EU AI Act risk tiers.
- Prohibited (Article 5): biometric manipulation, social scoring, subliminal manipulation — do not build.
- High-risk (Annex III): employment, credit, education, law enforcement, critical infrastructure — mandatory conformity assessment.
- Limited risk (Article 50): chatbots, deepfakes — transparency obligations only.
- Minimal risk: everything else — voluntary codes of practice.
- Use
references/eu-ai-act-risk-tiers.mdfor the full mapping. Document the tier in the feature spec.
- Map to NIST AI RMF functions.
- GOVERN: establish accountability, policies, roles, and documentation.
- MAP: identify risks and affected stakeholders.
- MEASURE: implement metrics, evals, red-teaming.
- MANAGE: apply mitigations, monitor in production, escalate incidents.
- Assign an owner to each function per feature.
- Implement PII detection and redaction.
- Scan all user inputs before they reach the model. Use a presidio or equivalent pipeline.
- Scrub before logging; never log raw PII.
- Define what to do when PII is found: redact and continue, or refuse and explain.
- Keep a list of PII categories in scope (names, emails, SSN, credit card, health identifiers).
- See
examples/pii-redaction.pyfor a working implementation.
- Defend against prompt injection.
- Apply instruction hierarchy: system prompt > retrieved context > user input. Never allow user input to override system instructions.
- Use delimiters (
<user_input>...</user_input>) to clearly bound user-controlled text. - Validate and sanitize output: if the output is used downstream (e.g., parsed as JSON, used to call a tool), apply strict schema validation.
- For agentic features, scope tool access to the minimum required; validate tool call parameters before execution.
- See
examples/prompt-injection-defense.mdfor concrete patterns.
- Implement output content filtering.
- Apply a classifier (OpenAI moderation API, Perspective API, or a fine-tuned classifier) to model outputs before they reach the user.
- Categories to filter: harmful content, hate speech, sexual content, self-harm, PII in outputs.
- Define thresholds per category and the action when a threshold is crossed (block, warn, escalate).
- Log filtered outputs with the classifier score for model card and audit purposes.
- Implement immutable audit logging.
- Log: timestamp (UTC), user ID (hashed or pseudonymized), session ID, model name + version, input token count, output token count, latency ms, safety filter result, any applied redactions.
- Use an append-only store (S3 with Object Lock, a write-only database table, or a SIEM).
- Retention period: consult legal. EU AI Act Article 12 requires high-risk systems to retain logs for a minimum defined period.
- Write a model card.
- Sections: Model details, Intended uses, Out-of-scope uses, Training data summary, Evaluation results (overall + by subgroup), Quantitative analysis (bias metrics), Ethical considerations, Caveats and recommendations.
- Base format on Hugging Face model card schema or the Mitchell et al. (2019) original.
- Refresh the card when the model is retrained or fine-tuned.
- Evaluate for bias and toxicity.
- Use a structured evaluation set that includes demographic parity slices (by inferred gender, ethnicity, age group — in the prompts, not from user profiles).
- Measure: toxic output rate, disparate refusal rate across demographic proxies, task success rate by slice.
- Tools:
evaluatelibrary (Hugging Face), Perspective API, ToxiGen, WinoBias, BBQ. - Document results in the model card. Publish known limitations.
- Cross-reference the product spec. Every safety control maps to a refusal or failure mode defined in
maximus-ai-product-spec. If the product spec has no safety section, add one before implementing controls.
Domain notes
- EU AI Act (Regulation (EU) 2024/1689) entered into force 1 August 2024. Prohibited practices (Article 5) apply from 2 February 2025; high-risk obligations (Annex III) from 2 August 2026. Prepare now.
- NIST AI RMF 1.0 (January 2023) is the US voluntary framework. Its four functions (Govern, Map, Measure, Manage) are the canonical US enterprise governance structure.
- Presidio (Microsoft, Apache 2.0) is the practical open-source choice for PII detection. It supports custom recognizers, supports 20+ entity types, and integrates with Hugging Face NER models.
- OpenAI Moderation API is free and sufficient for most output filtering. For custom categories or higher accuracy, fine-tune your own classifier.
- Prompt injection in agentic systems is a first-class threat (OWASP LLM Top 10, item LLM01). Do not treat it as a model problem — it's an architecture problem.
Gotchas
- PII in model outputs (the model regurgitating training data) is different from PII in inputs. Both need controls, but different ones.
- "Our system prompt tells the model not to do X" is not a safety control. It's a hint. Implement real controls on top.
- GDPR deletion requests apply to data used to train or fine-tune models. Coordinate with
maximus-ai-data-pipelinefor deletion workflows. - High-risk AI systems under the EU AI Act require a conformity assessment before market deployment. That's not a legal team problem — engineering needs to build the evidence trail.
- Audit logs that contain PII are themselves a GDPR liability. Scrub before logging, always.
Output
Model card document, audit log schema, PII redaction pipeline (see examples), prompt-injection defense patterns (see examples), EU AI Act tier classification, NIST AI RMF function assignments, bias evaluation report (numbers + methodology).
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
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.

