Skip to content

opensite-ai/opensite-skills / amazon-bedrock

amazon-bedrock

Flagged

Builds generative AI applications on Amazon Bedrock. Covers model invocation (Converse API, InvokeModel), RAG with Knowledge Bases, Bedrock Agents, Guardrails, and AgentCore (including the Harness managed agent loop). Applies when invoking models, setting up Knowledge Bases, creating agents, applying guardrails, deploying to AgentCore, migrating/porting/converting a Bedrock Agent (including inline agents) to an AgentCore Harness, troubleshooting Bedrock errors (ThrottlingException, AccessDeniedException), or choosing Bedrock models (Claude, Llama, Nova, Titan). Also for prompt caching, quota and throttling diagnosis, cost tracking, migrating between Claude model generations, chunking strategies, and Bedrock model selection. Covers AgentCore Payments (x402, microtransactions, Payment Manager, Connector, Instrument, Coinbase CDP, Stripe Privy, paid endpoints, agent payments). NOT for custom model training, Rekognition, or Comprehend. For SageMaker model discovery, customization, or endpoints, use aws-ai-ml.

FileKindSize
.aws-skill-metadataother18 B
SKILL.mdskill md34.1 KB
assets/kb_shim.py.tmplother3.4 KB
assets/lambda_shim.py.tmplother8.0 KB
assets/tool_schema.json.tmplother389 B
references/agentcore-credentials-and-security.mdmarkdown6.5 KB
references/agentcore-gateway.mdmarkdown7.0 KB
references/agentcore-harness.mdmarkdown22.0 KB
references/agentcore-memory-observability.mdmarkdown5.6 KB
references/agentcore-payments-setup-script.mdmarkdown12.3 KB
references/agentcore-payments-wiring.mdmarkdown12.1 KB
references/agentcore-payments.mdmarkdown19.5 KB
references/agentcore-registry-evaluations.mdmarkdown6.8 KB
references/agentcore-runtime-container-build.mdmarkdown10.4 KB
references/agentcore-runtime.mdmarkdown7.6 KB
references/agents-and-action-groups.mdmarkdown16.5 KB
references/bedrock-agents-to-agentcore-harness/cli.mdmarkdown2.0 KB
references/bedrock-agents-to-agentcore-harness/deploy.mdmarkdown12.0 KB
references/bedrock-agents-to-agentcore-harness/discovery.mdmarkdown3.9 KB
references/bedrock-agents-to-agentcore-harness/eligibility.mdmarkdown3.3 KB
references/bedrock-agents-to-agentcore-harness/mapping.mdmarkdown8.9 KB
references/cost-tracking.mdmarkdown4.5 KB
references/guardrails.mdmarkdown14.7 KB
references/knowledge-bases-decision-guide.mdmarkdown2.8 KB
references/knowledge-bases-retrieval.mdmarkdown8.3 KB
references/knowledge-bases-setup.mdmarkdown17.9 KB
references/managed-knowledge-bases-retrieval.mdmarkdown8.1 KB
references/managed-knowledge-bases-setup.mdmarkdown12.7 KB
references/migrate-bedrock-agents-to-agentcore-harness.mdmarkdown11.5 KB
references/model-invocation.mdmarkdown11.0 KB
references/model-migration.mdmarkdown4.3 KB
references/model-selection-guide.mdmarkdown7.4 KB
references/prompt-caching.mdmarkdown5.5 KB
references/prompt-engineering-by-model.mdmarkdown7.9 KB
references/quota-health.mdmarkdown4.3 KB
references/sdk-converse-api-python.mdmarkdown6.3 KB
references/sdk-converse-api-typescript.mdmarkdown6.5 KB
scripts/fetch_bedrock_agent.pyscript14.1 KB

references/managed-knowledge-bases-retrieval.md

View on GitHub
# Managed Knowledge Base (MKB) — Retrieval & Query Reference

> The AWS MCP server is recommended for executing these commands but is not required. `Retrieve` uses standard AWS CLI syntax; `AgenticRetrieveStream` is streaming and therefore **SDK-only** (boto3), shown inline below.

## Querying a Managed KB: use `Retrieve` or `AgenticRetrieveStream`

On a **managed** knowledge base, query with **`Retrieve`** (single-shot chunks) or **`AgenticRetrieveStream`** (agentic, streaming). `RetrieveAndGenerate` (a fully-synthesized answer with citations) is the Customer-managed path — see [customer-managed KB retrieval](knowledge-bases-retrieval.md). If you specifically need `RetrieveAndGenerate` behavior on a managed KB, verify support against the docs rather than assuming it is or isn't available.

## Query API decision

| API | Endpoint | When | Transport |
|---|---|---|---|
| `Retrieve` | `bedrock-agent-runtime` | Single-shot chunks for your own prompt/ranking | CLI or SDK |
| `AgenticRetrieveStream` | `bedrock-agent-runtime` | Agent plans → retrieves → evaluates → iterates across multiple KBs (check the quota); optional synthesized answer | **SDK only** (streaming; not the AWS CLI) |
| `RetrieveAndGenerate` | `bedrock-agent-runtime` | Customer-managed path (synthesized answer); verify MKB support against the docs | CLI or SDK |

## Retrieve (single-shot)

```bash
aws bedrock-agent-runtime retrieve --knowledge-base-id <kb-id> --retrieval-query '{"text":"<query>"}'
```

Metadata filtering, `numberOfResults`, and `overrideSearchType` work as for other KBs — the filter operator syntax is identical to the [customer-managed retrieval reference](knowledge-bases-retrieval.md#metadata-filtering-syntax); pass it under `retrievalConfiguration.vectorSearchConfiguration.filter`. Metadata attributes must have been present on the ingested documents to be filterable.

## AgenticRetrieveStream (agentic, streaming, SDK-only)

The AWS CLI cannot consume the response stream, so use boto3. Requires boto3/botocore >= 1.43.64 (which includes `agentic_retrieve_stream`; absent below that floor) — verify your installed version.

```python
import boto3

def agentic_retrieve(kb_ids, question, region="us-east-1", generate=True):
    """Run AgenticRetrieveStream against one or more MANAGED knowledge bases and
    print the streamed answer. `kb_ids` is a list of managed KB IDs (check the service quota for the max retrievers per request)."""
    if not isinstance(question, str) or not question.strip():
        raise ValueError("Provide a non-empty question.")
    if not kb_ids or not all(isinstance(k, str) and k.strip() for k in kb_ids):
        raise ValueError("Provide at least one knowledge base ID; each must be a non-empty string.")
    client = boto3.client("bedrock-agent-runtime", region_name=region)
    resp = client.agentic_retrieve_stream(
        messages=[{"role": "user", "content": [{"text": question}]}],
        retrievers=[
            {"configuration": {"knowledgeBase": {"knowledgeBaseId": kb_id}}}
            for kb_id in kb_ids  # multiple KBs per request; check the service quota for the max
        ],
        generateResponse=generate,  # for production, attach a guardrail via policyConfiguration (below) before exposing generated answers
        # Optional: agenticRetrieveConfiguration controls the planner/reranker models
        #   agenticRetrieveConfiguration={
        #       "foundationModelType": "MANAGED",   # or CUSTOM (+ foundationModelConfiguration)
        #       "maxAgentIteration": 5,             # check the API docs for the allowed range/default
        #       "rerankingModelType": "MANAGED",    # MANAGED | CUSTOM | NONE
        #   },
        # Optional guardrail — check the API docs for supported action modes (e.g. BLOCK):
        #   policyConfiguration={"bedrockGuardrailConfiguration": {"guardrailId": "<id>", "guardrailVersion": "<v>"}},
        # Optional ACL identity for document-level filtering:
        #   userContext={"userId": "<user>"},
    )

    answer, citations = [], []
    for event in resp["stream"]:
        if "responseEvent" in event:            # incremental generated answer chunks
            block = event["responseEvent"].get("output", {})
            if block.get("text"):
                answer.append(block["text"])
        elif "result" in event:                 # final result: retrieved refs + citations
            citations.append(event["result"])
        elif "traceEvent" in event:             # planner/iteration trace (optional to log)
            pass
        else:                                    # exception events surface as their own keys
            for k in ("validationException", "accessDeniedException", "throttlingException",
                      "resourceNotFoundException", "conflictException", "serviceQuotaExceededException",
                      "dependencyFailedException", "internalServerException", "badGatewayException"):
                if k in event:
                    raise RuntimeError(f"AgenticRetrieveStream {k}: {event[k].get('message')}")
    # NOTE: `answer` / `citations` may contain sensitive data (PII/PHI) from the KB —
    # do not log or surface without redaction / appropriate access controls.
    return "".join(answer), citations
```

- `messages` uses Converse-style content blocks (`[{"text": ...}]`).
- `retrievers` accepts multiple managed KBs (check the service quota for the max); each is `{"configuration": {"knowledgeBase": {"knowledgeBaseId": ...}}}`, with optional `retrievalOverrides` and a `description`.
- `generateResponse=False` returns retrieval results without a synthesized answer.
- Read the stream to completion; the terminal `result` event carries the retrieved references/citations.

## Considerations (from the API contract)

- **Managed KBs only.** `AgenticRetrieveStream` targets managed knowledge bases.
- **Guardrails.** Attach via `policyConfiguration`; check the AgenticRetrieveStream docs for which guardrail action modes (e.g. BLOCK, MASK) are supported on this path — not all modes may be available.
- **You provide the models.** The planner / embedding / reranking models are invoked with **your** IAM credentials — the caller's role needs `bedrock:InvokeModel` on those model ARNs.
- **Quotas.** Retrievers per request, results per call, and max iterations are governed by service quotas — check values rather than assuming.
- **Pagination.** `nextToken` continues a multi-part response.

## Security Considerations

- **Retrieved chunks can expose sensitive data.** Results (and the generated answer) return whatever the caller is authorized to see. Redact/classify PII/PHI before ingestion; use document-level ACL filtering via `userContext` where the connector supports it.
- **Guardrails on the generated answer.** Attach a Bedrock guardrail via `policyConfiguration` for the synthesized response; verify which action modes (e.g. BLOCK, MASK) the API supports rather than assuming, and don't rely on a mode you haven't confirmed.
- **Least-privilege model access.** Scope the caller's `bedrock:InvokeModel` to the specific planner/reranking/embedding model ARNs used — not `foundation-model/*`.
- **Audit + logging.** `Retrieve` / `AgenticRetrieveStream` are CloudTrail **data events** (not logged by default); enable data-event logging for `AWS::Bedrock::KnowledgeBase` to attribute who queried what. Always encrypt CloudWatch Logs log groups that receive Bedrock data events / retrieval traces with a customer-managed KMS key — retrieval results can expose any ingested data, not only PII.
- **Encryption in transit.** All data-plane calls use TLS; ensure endpoints are HTTPS.
- **Validate untrusted query input + rate-limit.** When the query text comes from end users, validate and sanitize it (enforce a max length, reject unexpected input) before calling `Retrieve` / `AgenticRetrieveStream`, and apply client-side rate limiting (per-user caps) to avoid abuse and service-quota exhaustion.
- **References.** [Amazon Bedrock security best practices](https://docs.aws.amazon.com/bedrock/latest/userguide/security-best-practices.html) and [Identity and access management for Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html).
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall