
Knowledge Base Injection
Teach your coding agent to inject only the right domain patterns into context via TF-IDF and semantic scoring instead of stuffing the whole system prompt.
Overview
knowledge-base-injection is a journey-wide agent skill that injects retrieved domain patterns into context at the right moment using TF-IDF and semantic scoring—usable whenever a solo builder needs deep vertical rules wi
Install
npx skills add https://github.com/itallstartedwithaidea/agent-skills --skill knowledge-base-injectionWhat is this skill?
- Retrieves domain patterns at task time instead of fine-tuning or static mega-prompts
- TF-IDF pattern matching plus semantic scoring for relevance
- Pattern schema: trigger, recommendation, evidence, and confidence score
- Production reference: gads-knowledge.js with 1,000+ curated Google Ads optimization patterns
- Positions Buddy™ at googleadsagent.ai as the reference implementation
- 1,000+ curated Google Ads optimization patterns in gads-knowledge.js
- Each pattern includes trigger, recommendation, evidence, and confidence score
Adoption & trust: 1 installs on skills.sh; 18 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
Your agent lacks reliable domain expertise because fine-tuning is expensive and stuffing every rule into the system prompt wastes context and dilutes focus.
Who is it for?
Builders creating specialized assistants who want a documented pattern library approach like the 1,000+ Google Ads patterns in gads-knowledge.js.
Skip if: One-off scripts with no recurring domain rules, or teams that only need a single static FAQ in the system prompt.
When should I use this skill?
When designing or extending agents that need domain-specific recommendations retrieved at runtime rather than baked into the base model or full system prompt.
What do I get? / Deliverables
You can design a retrieval-and-injection loop that pulls only high-scoring patterns (trigger, recommendation, evidence, confidence) into the active turn.
- Architecture for TF-IDF and semantic scoring over a pattern library
- Injection design mapping triggers to recommendations and evidence in the active turn
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Decide whether a curated pattern library beats fine-tuning for your vertical before you commit engineering time.
Implement scoring over triggers and confidence fields when the agent analyzes a live Google Ads account.
Regression-test that only relevant patterns inject per query and that low-confidence rules stay out of context.
Use evidence-backed patterns to explain recommended budget or keyword changes to stakeholders.
Add or retire patterns in the knowledge module as policies and platform APIs change.
How it compares
Use for dynamic pattern retrieval instead of fine-tuning the base model or pasting an entire policy manual into every request.
Common Questions / FAQ
Who is knowledge-base-injection for?
Solo and indie developers building domain-specific agents who need scalable expertise injection beyond generic LLM knowledge.
When should I use knowledge-base-injection?
During Idea research to scope KB shape, in Build when wiring retrieval and scoring, in Ship when validating pattern triggers, and in Grow when tuning patterns from live campaign or ops feedback.
Is knowledge-base-injection safe to install?
Check the Security Audits panel on this page; the skill describes techniques and references production modules—you still must review any code you copy and avoid leaking proprietary pattern data.
SKILL.md
READMESKILL.md - Knowledge Base Injection
# Knowledge Base Injection Part of [Agent Skills™](https://github.com/itallstartedwithaidea/agent-skills) by [googleadsagent.ai™](https://googleadsagent.ai) ## Description Knowledge Base Injection is the technique of dynamically injecting domain expertise into an agent's context at the moment it is most relevant, using TF-IDF pattern matching and semantic scoring. Generic language models lack the deep domain knowledge required for specialized tasks like Google Ads optimization, medical coding, or financial compliance. Rather than fine-tuning (expensive, slow, brittle) or bloating system prompts with everything the model might need (wasteful, dilutes attention), Knowledge Base Injection retrieves and injects only the specific patterns relevant to the current task. This skill is built on the production knowledge base system powering Buddy™ at [googleadsagent.ai™](https://googleadsagent.ai), specifically the `gads-knowledge.js` module containing over 1,000 curated Google Ads optimization patterns. Each pattern includes a trigger condition (when to apply it), a recommendation (what to do), evidence (why it works), and a confidence score. When Buddy™ analyzes a campaign, the knowledge base engine scores all patterns against the current context using TF-IDF and injects the top-K most relevant patterns into the agent's context, transforming a general-purpose model into a domain expert. The injection system operates on a retrieval-augmented generation (RAG) paradigm, but with a critical distinction: rather than retrieving raw documents, it retrieves structured action patterns with built-in confidence scores and applicability conditions. This produces more actionable, more reliable agent outputs than document-level RAG. ## Use When - The agent needs domain expertise that general-purpose models lack - You have a curated knowledge base of patterns, rules, or best practices - Fine-tuning is too expensive, too slow, or creates model version lock-in - Different queries require different subsets of domain knowledge - You want to update the agent's expertise without retraining or redeploying - The agent must ground its recommendations in verified, authoritative sources ## How It Works ```mermaid graph TD A[Agent Task/Query] --> B[Query Analyzer] B --> C[TF-IDF Scorer] C --> D[Knowledge Base<br/>1,000+ Patterns] D --> E[Ranked Results] E --> F{Score > Threshold?} F -->|Yes| G[Top-K Selection] F -->|No| H[Fallback: Broader Search] H --> G G --> I[Context Assembly] I --> J[Pattern Injection<br/>into Agent Context] J --> K[Agent Execution] K --> L[Citation Tracking] L --> M[Response with Sources] ``` When a task arrives, the query analyzer extracts key terms and concepts. The TF-IDF scorer computes relevance scores between the query and every pattern in the knowledge base. Patterns scoring above the threshold are ranked and the top-K are selected for injection. The selected patterns are assembled into a structured context block with clear formatting and injected into the agent's prompt. After execution, citation tracking links the agent's recommendations back to the specific patterns that informed them, providing auditability. ## Implementation **Knowledge Pattern Structure:** ```typescript interface KnowledgePattern { id: string; category: "bidding" | "targeting" | "creative" | "budget" | "structure" | "general"; trigger: string; recommendation: string; evidence: string; confidence: number; terms: string[]; tf_idf_vector?: number[]; } const SAMPLE_PATTERNS: KnowledgePattern[] = [ { id: "bid-001", category: "bidding", trigger: "Campaign using manual CPC with more than 30 conversions/month", recommend