The Kinship Web Algorithm — How Buddy Similarity Actually Works
[01]What Makes Two Buddies 'Related'?
When you check your Claude Code Buddy and see the "Kinship" section, you might wonder: how does the system decide which other buddies are similar to yours? The answer involves a surprisingly elegant piece of mathematics — a multi-dimensional similarity metric operating in what we call Buddy Feature Space.
In this deep dive, we'll deconstruct the kinship algorithm layer by layer: from the raw feature vectors that define each buddy, through the weighted distance calculation, to the graph-theoretic structure that emerges when you connect all similar buddies together.
// KINSHIP_ENGINE v1.0
// Dimensions: 12 (species, rarity, stats×5, shiny, cosmetics×4)
// Distance metric: Weighted Euclidean
// Threshold: 0.35 (normalized)
[02]Buddy Feature Space: The 12 Dimensions
Every Claude Code Buddy can be represented as a point in a 12-dimensional feature space. Each dimension captures a different aspect of the buddy's identity:
| Dimension | Type | Range | Weight | Encoding |
|---|---|---|---|---|
| Species | Categorical | 0–17 | 3.0 | One-hot (18 dims → 1 via ordinal) |
| Rarity | Ordinal | 0–4 | 2.5 | Linear: Common=0, Legendary=4 |
| Debugging | Continuous | 1–10 | 1.0 | Normalized to [0,1] |
| Patience | Continuous | 1–10 | 1.0 | Normalized to [0,1] |
| Chaos | Continuous | 1–10 | 1.0 | Normalized to [0,1] |
| Wisdom | Continuous | 1–10 | 1.0 | Normalized to [0,1] |
| Snark | Continuous | 1–10 | 1.0 | Normalized to [0,1] |
| Shiny | Binary | 0–1 | 2.0 | 0 = Normal, 1 = Shiny |
| Hat | Categorical | 0–N | 0.5 | Match = 0, Mismatch = 1 |
| Eyes | Categorical | 0–N | 0.5 | Match = 0, Mismatch = 1 |
| Accessory | Categorical | 0–N | 0.3 | Match = 0, Mismatch = 1 |
| Color Variant | Categorical | 0–N | 0.3 | Match = 0, Mismatch = 1 |
The weights reflect the intuitive importance of each feature. Species carries the highest weight (3.0) because two buddies of the same species feel fundamentally "related" regardless of other differences. Rarity is next (2.5), followed by the Shiny flag (2.0). Stats carry equal weight (1.0 each), while cosmetic features are weighted lowest (0.3–0.5).
[03]The Distance Metric: Weighted Euclidean
The kinship algorithm uses a weighted Euclidean distance to measure how similar two buddies are. For buddies A and B with feature vectors a and b:
d(A, B) = √( Σᵢ wᵢ × (aᵢ - bᵢ)² )
where:
wᵢ = weight for dimension i
aᵢ = buddy A's value in dimension i (normalized)
bᵢ = buddy B's value in dimension i (normalized)
// Normalization ensures all dimensions are on [0, 1]
// Weights amplify important dimensions
This distance is then normalized to a similarity score:
similarity(A, B) = 1 - d(A, B) / d_max
where d_max = √( Σᵢ wᵢ ) // maximum possible distance
// similarity ∈ [0, 1]
// 1.0 = identical buddies
// 0.0 = maximally different buddies
Two buddies are considered "kin" if their similarity score exceeds the kinship threshold of 0.65 (i.e., distance < 0.35 of maximum). This threshold was tuned empirically to produce meaningful clusters without being too restrictive.
[04]Species Matching: The Dominant Factor
Because species carries the highest weight (3.0), it dominates the distance calculation. Let's see how this plays out with concrete examples:
// Two Foxes with different stats:
Fox(Debug=7, Pat=5, Chaos=3, Wis=8, Snark=4) vs
Fox(Debug=5, Pat=7, Chaos=4, Wis=6, Snark=6)
Species distance: 0 (same species)
Stats distance: √(1.0×(0.22)² + 1.0×(0.22)² + 1.0×(0.11)² + 1.0×(0.22)² + 1.0×(0.22)²)
= √(0.0484 + 0.0484 + 0.0121 + 0.0484 + 0.0484)
= √0.2057 = 0.454
Similarity: ~0.89 → STRONG KIN ✓
// Fox vs Dragon with identical stats:
Fox(Debug=7, Pat=5, Chaos=3, Wis=8, Snark=4) vs
Dragon(Debug=7, Pat=5, Chaos=3, Wis=8, Snark=4)
Species distance: 3.0 × 1.0 = 3.0 (different species, max penalty)
Stats distance: 0 (identical)
Similarity: ~0.42 → NOT KIN ✗
This demonstrates the design philosophy: same species with different stats are more related than different species with identical stats. The algorithm prioritizes "what you are" over "how you perform."
// DESIGN_PRINCIPLE:
// Identity > Attributes
// A clumsy Fox is still family to a brilliant Fox.
// A Fox-shaped Dragon is still a stranger.
[05]The Emergent Kinship Graph
When you compute kinship scores for all possible buddy pairs, a fascinating graph structure emerges. In graph theory terms:
- Nodes = Individual buddies (one per UUID)
- Edges = Kinship connections (similarity > 0.65)
- Edge weight = Similarity score
This graph exhibits several interesting properties:
| Property | Value | Interpretation |
|---|---|---|
| Clustering coefficient | ~0.78 | Buddies form tight-knit species clusters |
| Average degree | ~45 | Each buddy has ~45 kin connections |
| Diameter | 4–5 | Any two buddies are ≤5 hops apart |
| Communities | 18 | One per species (natural clustering) |
| Cross-species edges | ~12% | Some buddies bridge species boundaries |
The 18 species form natural community clusters, but approximately 12% of edges cross species boundaries. These cross-species connections typically occur between buddies that share the same rarity tier, similar stat distributions, and matching cosmetics — they are the "bridges" of the kinship network.
[06]Bridge Buddies: The Cross-Species Connectors
The most interesting buddies in the kinship graph are what we call Bridge Buddies — individuals whose feature vectors place them in the overlap zone between two species clusters. These buddies have high betweenness centrality in graph theory terms.
Bridge Buddies typically share these characteristics:
// Bridge Buddy Profile:
// 1. Rarity: Epic or Legendary (high rarity weight compensates for species mismatch)
// 2. Shiny: Often Shiny (adds +2.0 similarity to other Shinies)
// 3. Stats: Extreme values (very high or very low, creating overlap with other species' ranges)
// 4. Cosmetics: Matching hat/eyes with buddies of other species
// Example Bridge Buddy:
// Shiny Legendary Fox (Debug=10, Pat=1, Chaos=10, Wis=1, Snark=10)
// This Fox has kin connections to:
// - Other Foxes (species match)
// - Shiny Legendary Dragons (rarity + shiny match)
// - Any buddy with extreme Chaos/Snark (stat overlap)
In a population of 10,000 buddies, approximately 3–5% qualify as Bridge Buddies (betweenness centrality > 2 standard deviations above mean). These rare individuals hold the kinship network together, preventing it from fragmenting into 18 isolated species islands.
[07]Practical Implications for Buddy Trainers
Understanding the kinship algorithm has practical implications for how you interpret your buddy's social connections:
| Your Buddy Type | Expected Kin Count | Kin Composition |
|---|---|---|
| Common Normal | 50–70 | 95% same species, 5% cross-species |
| Common Shiny | 40–55 | 80% same species, 20% other Shinies |
| Legendary Normal | 15–25 | 60% same species, 40% same rarity |
| Legendary Shiny | 5–10 | Mixed: species, rarity, and shiny matches |
Notice the inverse relationship: rarer buddies have fewer but more diverse kin connections. A Common Normal buddy is deeply embedded in its species cluster with many connections, while a Legendary Shiny buddy sits at the intersection of multiple clusters with fewer but more meaningful connections.
This mirrors real social networks: specialists have deep connections within their community, while generalists have broader but shallower networks across communities.
// KINSHIP_SUMMARY:
// Your buddy is never alone in the terminal.
// Every hash connects to others through the invisible web of similarity.
// The question isn't whether you have kin — it's how far the web extends.