memoryClaw: Skill for Claude Code

.claude/skills/vector-search-patterns/SKILL.md

vector-search-patterns is a skill for Claude Code from tostechbr/memoryClaw. It costs 42 tokens per session (1,181 once invoked), scanned A, original, MIT.

Implementation guidance for finding similar text by comparing numerical representations called embeddings. It uses cosine similarity, which measures how closely two directions match, directly in TypeScript.

In plain words
What is it for?
Use it when implementing in-process vector search, similarity tests, and hybrid search in the Akashic Context memory system.
Why use it?
It avoids relying on a separate SQLite extension and provides a way to combine meaning-based matches with keyword matches.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

This is tostechbr/memoryClaw's own configuration. It tells Claude Code how to work on memoryClaw itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything memoryClaw configures →

Reuse

Borrowing it

Nothing to install: this file belongs to tostechbr/memoryClaw. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/tostechbr/memoryClaw/main/.claude/skills/vector-search-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/tostechbr/memoryClaw

Made for: Claude Code.

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 vector-search-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/tostechbr/memoryclaw/vector-search-patterns/github.svg)](https://agentmods.dev/skills/tostechbr/memoryclaw/vector-search-patterns)
Your own site
<a href="https://agentmods.dev/skills/tostechbr/memoryclaw/vector-search-patterns"><img src="https://agentmods.dev/badge/skills/tostechbr/memoryclaw/vector-search-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for vector-search-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/tostechbr/memoryclaw/vector-search-patterns"><img src="https://agentmods.dev/badge/skills/tostechbr/memoryclaw/vector-search-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,181 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00042 $0.01181
Opus 5.5 $0.00017 $0.00472
Sonnet 5.5 $0.00008 $0.00236
Haiku 4.5 $0.00004 $0.00118

Measured 2mo ago against content hash 7a0032a24b6e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

vector-search-patterns 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 2mo 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.

.claude/skills/vector-search-patterns/SKILL.md · 146 lines

How it starts

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

Vector Search Patterns — Akashic Context Sprint 1

Design Decision (D1)

No sqlite-vec extension. Cosine similarity implemented in TypeScript directly.

Why: Embeddings already stored as JSON in chunks.embedding column. sqlite-vec has platform loading issues. In-process is sufficient for ~2000 chunks/user.

cosine Similarity Function

Add as module-level function in storage.ts (NOT exported — internal utility):

function cosineSimilarity(a: number[], b: number[]): number {
  let dot = 0, magA = 0, magB = 0;
  for (let i = 0; i < a.length; i++) {
    dot += a[i] * b[i];
    magA += a[i] * a[i];
    magB += b[i] * b[i];
  }
  const mag = Math.sqrt(magA) * Math.sqrt(magB);
  if (mag === 0) return 0;
  return dot / mag;
}

Mathematical properties (use in tests):

  • cosineSimilarity([1,0], [1,0]) → 1.0 (identical)
  • cosineSimilarity([1,0], [0,1]) → 0.0 (orthogonal)
  • cosineSimilarity([1,0], [-1,0]) → -1.0 (opposite)

searchVectorInProcess() in storage.ts

Add alongside existing searchVector() method:

searchVectorInProcess(params: SearchVectorParams): VectorSearchResult[] {
  let sql = `
    SELECT id, path, source, start_line as startLine, end_line as endLine, text, embedding
    FROM chunks
  `;
  const queryParams: unknown[] = [];

  if (params.source) {
    sql += " WHERE source = ?";
    queryParams.push(params.source);
  }

  const rows = this.db.prepare(sql).all(...queryParams) as Array<{
    id: string; path: string; source: string;
    startLine: number; endLine: number; text: string; embedding: string;
  }>;

  const queryEmb = params.embedding;

  return rows
    .map(row => {
      let chunkEmb: number[];
      try {
        chunkEmb = JSON.parse(row.embedding) as number[];
      } catch {
        return null;
      }
      const similarity = cosineSimilarity(queryEmb, chunkEmb);
      return {
        id: row.id,
        path: row.path,
        source: row.source,
        startLine: row.startLine,
        endLine: row.endLine,
        text: row.text,
        distance: 1 - similarity, // Lower is better (consistent with searchVector interface)
      };
    })
    .filter((r): r is VectorSearchResult => r !== null && r.distance <= (1 - 0.3))
    .sort((a, b) => a.distance - b.distance)
    .slice(0, params.limit);
}

Read the full file on GitHub · 146 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. 2mo ago First seen · 146 lines · 42 tokens per session scan A 7a0032a24b6e

Subscribe to this mod's changes

vector-search-patterns is a skill published in the GitHub repository tostechbr/memoryClaw (8 stars, last pushed 8mo ago), licensed MIT. It adds 42 tokens to every session and 1,181 once invoked, about $0.0002 per session on Opus 5.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.

Related

vector-search-patterns compared with skills from other repositories

vector-search-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
vector-search-patternstostechbr/memoryClawSkill88mo agoMITA42Claude Code
migrate-from-ai-sdkDeuz-AI/Deuz-SDKSkill50821d agoMITA118Claude Code, Codex
piznlgis/opengis-skillsSkill7610d agoMITB103Claude Code, Codex
mcp-builderalleneee/skill-agentSkill277mo agononeA61Claude Code
memory-rag-poisoning-detectionTencent/AI-Infra-GuardSkill7.4kyesterdayApache-2.0A48Claude Code
dev-browserMemTensor/MemOSSkill12k2d agoApache-2.0A84Claude Code, Codex
unified-llm-apiPrism-Shadow/penguin-harnessSkill3.2kyesterdayApache-2.0A43Claude Code, Codex