# Bedrock RAG

> Indexes local markdown into a Bedrock-backed retrieval workflow.

- Skill: `sahit-sai/bedrock-rag` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add sahit-sai/bedrock-rag`
- Raw SKILL.md: https://api.skillmd.com/api/skills/sahit-sai/bedrock-rag/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: sahit-sai (https://skillmd.com/u/sahit-sai)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/sahit-sai/bedrock-rag

---


# bedrock-rag

## Purpose

Chunks local markdown corpora and syncs them into an Amazon Bedrock Knowledge Base for semantic retrieval.

## Runbook

1. Verify `aws`, `python3`, and `jq` are in PATH, then validate credentials with `aws sts get-caller-identity --no-cli-pager`.
2. Confirm `BEDROCK_KB_ID` and `BEDROCK_MODEL_ID` are set, and ensure `AWS_REGION` matches the Bedrock region hosting the knowledge base.
3. Run `scripts/chunk.sh SOURCE_DIR` to split all `.md` files into roughly 500-word JSONL chunks containing `chunk_id`, `source_file`, and `content`.
4. Review the chunk count before indexing; abort if the chunk count exceeds `1000` unless `FORCE=1` is explicitly set.
5. Run `scripts/index.sh CHUNKS_PATH` to sync the chunk stream into the Bedrock Knowledge Base. The script ingests documents and then triggers a Bedrock ingestion job for auditable sync status.
6. Poll `aws bedrock-agent get-ingestion-job` until the job reports `COMPLETE`; abort on `FAILED` or `STOPPED`.
7. Run `scripts/query.sh "your question"` to verify semantic retrieval and inspect the returned citations.

## Stop conditions

1. Abort if `aws sts get-caller-identity` fails.
2. Abort if chunk count exceeds `1000` unless `FORCE=1`.
3. Never delete existing knowledge-base contents — only add or update documents.
4. Abort if the Bedrock ingestion job returns `FAILED` or `STOPPED`.

## Output format

```json
{
  "chunks_synced": 128,
  "kb_id": "KB12345678",
  "model_id": "anthropic.claude-3-sonnet-20240229-v1:0",
  "sync_status": "COMPLETE"
}
```

## Example invocations

- `skills/bedrock-rag/scripts/chunk.sh docs > docs/.bedrock-rag.chunks.jsonl`
- `skills/bedrock-rag/scripts/index.sh docs/.bedrock-rag.chunks.jsonl`
- `skills/bedrock-rag/scripts/query.sh "What deployment steps are documented?"`
- `skills/bedrock-rag/scripts/run.sh docs --query "What changed in the onboarding guide?"`

