rag-code-gen

rag-code-gen is a skill for Claude Code, Codex from Smart-AI-Memory/attune-ai. It costs 50 tokens per session (715 once invoked), scanned A, original, Apache-2.0.

A code-generation tool that first searches a collection of Attune documentation and uses the matching material to guide its answers. Its output includes links to the sources it used.

In plain words
What is it for?
Use it when generating code, configuration, or explanations that must follow Attune documentation. You can specify a particular Attune feature and choose how deeply to search.
Why use it?
It reduces the chance of invented APIs, workflow names, or usage patterns by tying generated code to reference documents. The citations let you check the basis for the answer.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/smart-ai-memory/attune-ai/rag-code-gen
Any agent
npx skills add Smart-AI-Memory/attune-ai --skill rag-code-gen
Clone the repo
git clone --depth 1 https://github.com/Smart-AI-Memory/attune-ai

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rag-code-gen

README.md
[![agentmods](https://agentmods.dev/badge/skills/smart-ai-memory/attune-ai/rag-code-gen.svg)](https://agentmods.dev/skills/smart-ai-memory/attune-ai/rag-code-gen)
Your own site
<a href="https://agentmods.dev/skills/smart-ai-memory/attune-ai/rag-code-gen"><img src="https://agentmods.dev/badge/skills/smart-ai-memory/attune-ai/rag-code-gen.svg" alt="Measured on agentmods" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 715 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00050 $0.00715
Opus 5 $0.00025 $0.00358
Sonnet 5 $0.00010 $0.00143
Haiku 4.5 $0.00005 $0.00072

Measured 5d ago against content hash 4f24c3292354, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rag-code-gen scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/rag-code-gen/SKILL.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RAG-grounded code generation

attune-rag ships with attune-ai core (pip install attune-ai). Grounds code generation in the attune-help template corpus so outputs cite real APIs, workflow names, and patterns instead of hallucinating them. Every output ends with a ## Sources block of clickable citations.

Scoping

Before running, ask:

  1. What are you trying to produce? Code, config, explanation, or a mix?
  2. Any specific attune surface? e.g. "the security-audit workflow", "MCP tool pattern", "BaseWorkflow subclass". Helps retrieval hit the right concept file.
  3. Depth? Default is standard. quick saves time and budget for simple asks; deep is for complex multi-file or architectural questions.

Running

attune workflow run rag-code-gen \
  --input '{"query": "<the request>"}'

Optional inputs:

  • k — max grounding docs to retrieve (default 3)
  • depthquick / standard / deep
  • feedback — pass good or bad AFTER inspecting the output to record a verdict against every cited template
  • model — override the generator model if you need to

Output shape

WorkflowResult.final_output is a string with two parts:

  1. The generated code / explanation
  2. A ## Sources section listing each cited attune-help template with its category, retrieval score, and a clickable link to the source on GitHub

WorkflowResult.metadata carries the full citation dict (query, retriever_name, retrieved_at, hits[]) plus fallback_used and confidence so callers can make routing decisions.

When RAG doesn't help

If the retriever can't find relevant templates, the workflow still runs — it falls back to an unaugmented prompt that explicitly tells the model there is NO grounding context so it should say "I don't know about attune X" rather than invent. metadata.fallback_used is True in that case.

Alternative: MCP tool only (no LLM call)

If you want just retrieval without generation, use the rag_knowledge_query MCP tool directly. It returns hits + an augmented prompt string without calling an LLM itself — handy for routing decisions, agent planning, or feeding another model.

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 84 lines · 50 tokens per session scan A 4f24c3292354

Subscribe to this mod's changes

rag-code-gen is a skill published in the GitHub repository Smart-AI-Memory/attune-ai (10 stars, last pushed yesterday), licensed Apache-2.0. It adds 50 tokens to every session and 715 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.