aws-genai-lens
Skill3 starsChanged 8 months agoCC0-1.0View on GitHub
Enforces AWS Well-Architected Generative AI Lens best practices for foundation model workloads on Amazon Bedrock and SageMaker AI. Use when designing GenAI architectures, implementing RAG pipelines, selecting foundation models, configuring Bedrock Guardrails, fine-tuning models, optimizing GenAI costs, securing AI workloads, or applying responsible AI principles including fairness, explainability, and safety.
In this repository48 other files it gives its agents.
- 3d-printingSkill
- app-securitySkill
- architecture-designSkill
- aws-well-architected-frameworkSkill
- aws-well-architectedSkill
- azure-well-architectedSkill
- blog-post-with-diagramsSkill
- clean-architectureSkill
- clean-codeSkill
- databricks-genie-spaces-best-practicesSkill
- data-visualization-guideSkill
- design-an-interfaceSkill
- design-patternsSkill
- domain-driven-designSkill
- dry-principleSkill
- edit-articleSkill
- event-driven-designSkill
- git-best-practicesSkill
- git-guardrails-claude-codeSkill
- grill-meSkill
- hexagonal-architectureSkill
- improve-codebase-architectureSkill
- language-conventions-source-en-docs-brSkill
- learn-electronicsSkill
- linked-dataSkill
- microservices-skillSkill
- object-oriented-programmingSkill
- oop-design-patternsSkill
- oreilly-design-referenceSkill
- organize-docs-from-zipSkill
- prd-to-issuesSkill
- prd-to-planSkill
- project-context-syncSkill
- request-refactor-planSkill
- rfc2119Skill
- scaffold-exercisesSkill
- semverSkill
- setup-pre-commitSkill
- solid-principlesSkill
- tddSkill
- todoSkill
- triage-issueSkill
- ts-otp-awsSkill
- ubiquitous-languageSkill
- ux-design-principlesSkill
- write-a-prdSkill
- write-a-skillSkill
- yagni-principleSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
40 rules. About 0 are common, 40 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈40
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 60
MUST start with prompt engineering and evaluate before investing in RAG or fine-tuning
- Distinctive: line 61
MUST benchmark multiple models on representative tasks before selecting
- Distinctive: line 62
SHOULD use the smallest model that meets quality requirements — model right-sizing is the single biggest cost lever
- Distinctive: line 81
MUST implement a centralized prompt catalog with version control — treat prompts as code
- Distinctive: line 82
MUST separate system prompts from user input to prevent instruction override
- Distinctive: line 83
MUST use few-shot examples for tasks requiring consistent format or style
- Distinctive: line 84
SHOULD implement prompt templates with variable substitution for maintainability
- Distinctive: line 85
SHOULD measure and track prompt performance metrics (quality, latency, cost)
- Distinctive: line 89
MUST use Bedrock Guardrails Prompt Attack filter on all user-facing endpoints
- Distinctive: line 90
MUST sanitize and validate all user inputs before sending to the model
- Distinctive: line 91
MUST assume injection CAN succeed — design defense-in-depth (input filtering + output validation + action authorization)
- Distinctive: line 92
SHOULD separate system instructions from user content using clear delimiters
- Distinctive: line 93
MUST NOT trust model output for security-critical decisions without validation
- Distinctive: line 127
MUST implement contextual grounding checks to detect hallucination in RAG responses
- Distinctive: line 128
SHOULD use hybrid search (vector + keyword) for better retrieval precision
- Distinctive: line 129
SHOULD evaluate retrieval quality separately from generation quality
- Distinctive: line 130
SHOULD implement metadata filtering to narrow retrieval scope
- Distinctive: line 136
SHOULD fine-tune only when prompt engineering + RAG cannot achieve the required quality for behavior or style.
- Distinctive: line 149
MUST establish baseline metrics with prompting + RAG before fine-tuning
- Distinctive: line 150
MUST maintain a high-quality evaluation dataset throughout the fine-tuning process
- Distinctive: line 151
SHOULD use LoRA as the default fine-tuning approach for cost efficiency
- Distinctive: line 170
MUST implement safety guardrails on all production FM endpoints
- Distinctive: line 171
MUST document model limitations and known failure modes
- Distinctive: line 172
SHOULD establish AI governance processes before production deployment
- Distinctive: line 189
MUST configure content filters on all user-facing FM endpoints
- Distinctive: line 190
MUST enable PII detection for workloads handling personal data
- Distinctive: line 191
SHOULD enable contextual grounding checks for all RAG workloads
- Distinctive: line 209
MUST right-size the model — use the smallest model meeting quality requirements
- Distinctive: line 210
SHOULD implement prompt caching for repeated prefixes (system prompts, few-shot examples)
- Distinctive: line 211
SHOULD use batch processing for non-real-time workloads (up to 50% cost savings)
- Distinctive: line 212
SHOULD implement intelligent routing by query complexity (simple queries → smaller model)
- Distinctive: line 213
SHOULD set agent stopping conditions to prevent runaway loops
- Distinctive: line 214
SHOULD optimize prompt length — shorter prompts with same quality reduce per-request cost
- Distinctive: line 222
MUST enforce least privilege IAM policies for all FM endpoint access
- Distinctive: line 223
MUST use AWS PrivateLink for private VPC-to-Bedrock connections in production
- Distinctive: line 224
MUST use customer-managed KMS keys for encryption of model inputs/outputs and fine-tuning data
- Distinctive: line 225
MUST enable CloudTrail logging for all Bedrock API calls
- Distinctive: line 226
SHOULD implement defense-in-depth: IAM → VPC → WAF → Guardrails → input validation → output encoding
- Distinctive: line 227
SHOULD use Bedrock AgentCore with Cedar policy language to enforce boundaries on agent tool calls
- Distinctive: line 235
When designing or reviewing a GenAI workload on AWS:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
AWS Well-Architected Generative AI Lens
Reference: AWS GenAI Lens (updated Nov 2025)
When to Apply
- Designing GenAI architectures on AWS (Bedrock, SageMaker AI)
- Implementing RAG pipelines with vector stores and knowledge bases
- Selecting foundation models and deciding between prompting, RAG, and fine-tuning
- Configuring guardrails for content safety, PII protection, and hallucination detection
- Optimizing GenAI workload costs (model selection, caching, batching)
- Securing AI workloads (prompt injection defense, data protection, access control)
- Applying responsible AI principles to production FM workloads
GenAI Design Principles
- Design for controlled autonomy — bound agent actions with explicit guardrails and stopping conditions
- Implement comprehensive observability — monitor prompts, responses, latency, cost, and quality metrics
- Optimize resource efficiency — right-size models; use caching and batching to reduce cost
- Establish distributed resilience — design for FM endpoint failures, throttling, and degraded responses
- Standardize resource management — centralize model access, prompt catalogs, and configuration
- Secure interaction boundaries — validate inputs, filter outputs, enforce least privilege on FM endpoints
Lifecycle Phases
| Phase | Key Activities |
| 1. Scoping | Define the business problem; determine if GenAI is the right solution; identify success metrics |
| 2. Model Selection | Evaluate models by modality, accuracy, latency, cost, and context window; benchmark candidates |
| 3. Customization | Prompt engineering → RAG → fine-tuning (progressive investment); evaluate after each stage |
| 4. Development & Integration | Build application logic, implement guardrails, integrate with existing systems |
| 5. Deployment | Deploy to production with monitoring, scaling, and rollback capability |
| 6. Continuous Improvement | Monitor quality metrics; refine prompts, retrieval, and models; manage model lifecycle |
Model Selection and Customization Strategy
Decision Tree
Start with prompt engineering (lowest cost, fastest iteration)
↓ Not meeting quality bar?
Add RAG for knowledge-grounded tasks
↓ Still not meeting quality bar?
Fine-tune when behavior/style is the bottleneck
↓ Need maximum control?
Custom training via SageMaker HyperPod- MUST start with prompt engineering and evaluate before investing in RAG or fine-tuning
- MUST benchmark multiple models on representative tasks before selecting
- SHOULD use the smallest model that meets quality requirements — model right-sizing is the single biggest cost lever
Model Selection Criteria
| Criterion | Considerations |
| Modality | Text, image, audio, video, multi-modal, embedding |
| Quality | Accuracy on your task benchmarks; reasoning capability |
| Context Window | How much input context the task requires |
| Latency | Real-time vs batch tolerance |
| Cost | Per-token pricing; throughput pricing; reserved capacity |
| Provider | Anthropic, Meta, Mistral, Amazon, Cohere, AI21, Stability AI (via Bedrock) |
Prompt Engineering
Rules
- MUST implement a centralized prompt catalog with version control — treat prompts as code
- MUST separate system prompts from user input to prevent instruction override
- MUST use few-shot examples for tasks requiring consistent format or style
- SHOULD implement prompt templates with variable substitution for maintainability
- SHOULD measure and track prompt performance metrics (quality, latency, cost)
Prompt Injection Defense
- MUST use Bedrock Guardrails Prompt Attack filter on all user-facing endpoints
- MUST sanitize and validate all user inputs before sending to the model
- MUST assume injection CAN succeed — design defense-in-depth (input filtering + output validation + action authorization)
- SHOULD separate system instructions from user content using clear delimiters
- MUST NOT trust model output for security-critical decisions without validation
RAG (Retrieval-Augmented Generation)
RAG augments FM responses with retrieved knowledge, reducing hallucination and keeping responses grounded.
Amazon Bedrock Knowledge Bases
Automates the full RAG pipeline: ingestion → chunking → embedding → vector storage → retrieval → prompt augmentation.
Vector Store Options
| Store | Best For | Key Feature |
| OpenSearch Serverless | General-purpose vector search | Fully managed; hybrid search (vector + keyword) |
| Aurora PostgreSQL (pgvector) | Teams already using Aurora | Familiar SQL; transactional consistency |
| Neptune Analytics | Knowledge graph + vector (GraphRAG) | Links related content; improves complex reasoning |
| Amazon S3 Vectors (2025) | High-scale, cost-sensitive workloads | Up to 2B vectors/index; ~90% cost reduction vs specialized DBs |
| MongoDB Atlas | MongoDB-native teams | Atlas Vector Search integration |
| Pinecone | Dedicated vector DB teams | Purpose-built vector search |
Chunking Strategies
| Strategy | Use When |
| Fixed-size | Uniform content; simple implementation |
| Semantic | Content with natural topic boundaries |
| Hierarchical | Content with parent-child structure (sections, subsections) |
| Custom (Lambda) | Domain-specific chunking logic required |
RAG Quality Rules
- MUST implement contextual grounding checks to detect hallucination in RAG responses
- SHOULD use hybrid search (vector + keyword) for better retrieval precision
- SHOULD evaluate retrieval quality separately from generation quality
- SHOULD implement metadata filtering to narrow retrieval scope
Fine-Tuning
SHOULD fine-tune only when prompt engineering + RAG cannot achieve the required quality for behavior or style.
Approaches
| Approach | Use When | Cost |
| Supervised Fine-Tuning (SFT) | Specific task format or domain style | Moderate |
| Continued Pre-Training | Domain-specific vocabulary and knowledge | High |
| LoRA (Low-Rank Adaptation) | Resource-efficient task adaptation | Low — dramatically less compute |
| QLoRA | Fine-tuning on limited GPU memory | Very low |
| Model Distillation | Compress a large model's capability into a smaller one | Moderate |
| Reinforcement Fine-Tuning (2025) | Align model behavior with human preferences | High — but avg 66% accuracy gain |
- MUST establish baseline metrics with prompting + RAG before fine-tuning
- MUST maintain a high-quality evaluation dataset throughout the fine-tuning process
- SHOULD use LoRA as the default fine-tuning approach for cost efficiency
Responsible AI
Eight Dimensions
| Dimension | Key Practices |
| Fairness | Bias detection and auditing across demographics; diverse evaluation datasets |
| Explainability | Interpretable decisions; document model limitations and known failure modes |
| Privacy & Security | Encryption at rest/transit; access controls; regulatory compliance (GDPR, HIPAA) |
| Safety | Content filtering; guardrails; output validation; harmful content prevention |
| Controllability | Human oversight; monitoring; ability to adjust or override model behavior |
| Veracity & Robustness | Accuracy validation; automated reasoning for hallucination detection; adversarial testing |
| Governance | AI review committees; model cards; documentation; escalation procedures |
| Transparency | Clear disclosure that content is AI-generated; model provenance documentation |
- MUST implement safety guardrails on all production FM endpoints
- MUST document model limitations and known failure modes
- SHOULD establish AI governance processes before production deployment
Amazon Bedrock Guardrails
Six safeguard policies applied on both inbound prompts and outbound responses:
| Policy | Purpose | Configuration |
| Content Filters | Block hate, insults, sexual, violence, misconduct, prompt attack | Configurable strength per category |
| Denied Topics | Block up to 30 specific topics | Natural language topic descriptions |
| Word Filters | Exact-match blocking of specific words | Word list management |
| Sensitive Information Filters | Detect and block/mask PII | ML-based detection; block or mask options |
| Contextual Grounding Checks | Detect hallucination in RAG responses | Grounding score threshold |
| Automated Reasoning Checks | Formal mathematical logic verification | "First GenAI safeguard to use formal logic" |
- MUST configure content filters on all user-facing FM endpoints
- MUST enable PII detection for workloads handling personal data
- SHOULD enable contextual grounding checks for all RAG workloads
- The ApplyGuardrail API works with ANY model, including self-hosted or third-party
Cost Optimization
Pricing Models
| Model | Use When |
| On-Demand (per token) | Variable, unpredictable workloads; development and testing |
| Provisioned Throughput | Sustained, predictable production workloads; guaranteed capacity |
| Batch (up to 50% discount) | Non-real-time processing; bulk document analysis |
| Cross-Region Inference | Need lower latency or higher availability across regions |
Cost Reduction Strategies
- MUST right-size the model — use the smallest model meeting quality requirements
- SHOULD implement prompt caching for repeated prefixes (system prompts, few-shot examples)
- SHOULD use batch processing for non-real-time workloads (up to 50% cost savings)
- SHOULD implement intelligent routing by query complexity (simple queries → smaller model)
- SHOULD set agent stopping conditions to prevent runaway loops
- SHOULD optimize prompt length — shorter prompts with same quality reduce per-request cost
Security
Rules
- MUST enforce least privilege IAM policies for all FM endpoint access
- MUST use AWS PrivateLink for private VPC-to-Bedrock connections in production
- MUST use customer-managed KMS keys for encryption of model inputs/outputs and fine-tuning data
- MUST enable CloudTrail logging for all Bedrock API calls
- SHOULD implement defense-in-depth: IAM → VPC → WAF → Guardrails → input validation → output encoding
- SHOULD use Bedrock AgentCore with Cedar policy language to enforce boundaries on agent tool calls
Key guarantee: Amazon Bedrock does not allow model providers to learn from customer data or prompts.
Checklist
When designing or reviewing a GenAI workload on AWS:
- Business problem is clearly defined; GenAI is confirmed as the right approach
- Model selection is based on benchmarks, not assumptions; smallest effective model chosen
- Prompt engineering is exhausted before adding RAG; RAG before fine-tuning
- Centralized prompt catalog exists with version control
- Prompt injection defenses are implemented (Guardrails + input validation + defense-in-depth)
- RAG pipeline uses appropriate chunking and includes contextual grounding checks
- Bedrock Guardrails are configured: content filters, PII detection, and denied topics at minimum
- Cost optimization applied: model right-sizing, caching, batching where applicable
- IAM least privilege, PrivateLink, KMS encryption, and CloudTrail are configured
- Responsible AI dimensions are addressed: safety, fairness, transparency, governance
- Monitoring covers: latency, cost per request, quality metrics, guardrail triggers, error rates
Key References
| Book / Resource | Author(s) | Publisher | Year |
| AWS Well-Architected Generative AI Lens (official) | AWS | AWS Docs | 2025 |
| AI Engineering | Chip Huyen | O'Reilly | 2025 |
| Generative AI on AWS | Fregly, Barth, Eigenbrode | O'Reilly | 2023 |
| Hands-On Large Language Models | Jay Alammar, Maarten Grootendorst | O'Reilly | 2024 |
| Build a Large Language Model (From Scratch) | Sebastian Raschka | Manning | 2024 |
| Designing Machine Learning Systems | Chip Huyen | O'Reilly | 2022 |
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.

