pgvector-knowledge-patch
pgvector changes since training cutoff (latest: 0.8.2) — halfvec, sparsevec, bit indexing, binary quantization, iterative index scans, subvector extraction, L1 distance. Load before working with pgvector.
What this skill does
# pgvector 0.7+ Knowledge Patch
Claude's baseline knowledge covers pgvector through 0.6.x. This skill provides features from 0.7.0 (Apr 2024) onwards.
**Source**: pgvector GitHub at https://github.com/pgvector/pgvector
## Reference Files
- **[`references/vector-types-and-indexing.md`](references/vector-types-and-indexing.md)** — halfvec, sparsevec, bit indexing, binary quantization, expression indexes, subvector extraction
- **[`references/iterative-index-scans.md`](references/iterative-index-scans.md)** — iterative scan modes, overfiltering solutions, scan limits, CTE patterns
## Quick Reference: New Vector Types (0.7.0)
| Type | Description | Max Indexed | Format |
|------|-------------|-------------|--------|
| `halfvec(n)` | Half-precision (float16) vectors | 4,000 dims | Same as vector |
| `sparsevec(n)` | Sparse vectors | 1,000 non-zero | `'{1:val,3:val}/dims'` (1-indexed) |
| `bit(n)` indexing | Binary vector search | 64,000 dims | Standard bit type |
## Quick Reference: New Functions (0.7.0)
| Function | Purpose |
|----------|---------|
| `binary_quantize(vector)` | Convert vector to bit (positive -> 1, else -> 0) |
| `subvector(vector, start, length)` | Extract subvector (1-indexed) |
| `l2_normalize(vector)` | L2 normalize a vector |
| `vector \|\| vector` | Concatenate vectors |
## Quick Reference: New Operator Classes (0.7.0)
| Type | L2 | Inner Product | Cosine |
|------|----|----|--------|
| halfvec | `halfvec_l2_ops` | `halfvec_ip_ops` | `halfvec_cosine_ops` |
| sparsevec | `sparsevec_l2_ops` | `sparsevec_ip_ops` | `sparsevec_cosine_ops` |
| Type | Hamming (`<~>`) | Jaccard (`<%>`) |
|------|-----------------|-----------------|
| bit | `bit_hamming_ops` | `bit_jaccard_ops` |
HNSW now also supports L1 distance with `vector_l1_ops`.
## Quick Reference: Iterative Index Scans (0.8.0)
Solves the "overfiltering" problem — when `WHERE` clauses with approximate indexes return too few results.
```sql
-- Enable for HNSW (strict = exact distance order; relaxed = better recall)
SET hnsw.iterative_scan = strict_order; -- or relaxed_order
SET hnsw.max_scan_tuples = 20000; -- default; max tuples to visit
-- Enable for IVFFlat (relaxed_order ONLY — no strict_order support)
SET ivfflat.iterative_scan = relaxed_order;
SET ivfflat.max_probes = 100; -- max probes for iterative scans
```
## Half-Precision Expression Index (0.7.0)
```sql
CREATE INDEX ON items USING hnsw ((embedding::halfvec(3)) halfvec_l2_ops);
SELECT * FROM items ORDER BY embedding::halfvec(3) <-> '[1,2,3]' LIMIT 5;
```
## Binary Quantization Expression Index (0.7.0)
```sql
CREATE INDEX ON items USING hnsw ((binary_quantize(embedding)::bit(3)) bit_hamming_ops);
-- Re-rank for better recall:
SELECT * FROM (
SELECT * FROM items ORDER BY binary_quantize(embedding)::bit(3) <~> binary_quantize('[1,-2,3]') LIMIT 20
) ORDER BY embedding <=> '[1,-2,3]' LIMIT 5;
```
## Iterative Scan CTE Patterns (0.8.0)
**Materialized CTE for strict ordering with relaxed scans:**
```sql
WITH relaxed_results AS MATERIALIZED (
SELECT id, embedding <-> '[1,2,3]' AS distance FROM items
WHERE category_id = 123 ORDER BY distance LIMIT 5
) SELECT * FROM relaxed_results ORDER BY distance + 0;
```
Note: `+ 0` is needed for Postgres 17+ to force re-sorting.
**Distance filter pattern** (place distance filter outside CTE):
```sql
WITH nearest AS MATERIALIZED (
SELECT id, embedding <-> '[1,2,3]' AS distance FROM items ORDER BY distance LIMIT 5
) SELECT * FROM nearest WHERE distance < 5 ORDER BY distance;
```
## Array to sparsevec Cast (0.8.0)
```sql
SELECT ARRAY[1,0,2,0,3]::sparsevec; -- '{1:1,3:2,5:3}/5'
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.