affinity-python-sdk

affinity-python-sdk is a skill for Claude Code from yaniv-golan/affinity-sdk. It costs 20 tokens per session (4,842 once invoked), scanned A, original, MIT.

A set of instructions for writing Python code with the Affinity SDK, a programming interface for accessing Affinity CRM data.

In plain words
What is it for?
Use it to initialize synchronous or asynchronous Affinity clients, read CRM records, and write automation that follows the SDK's write-permission rules.
Why use it?
It encourages read-only access by default, reducing the chance that a script changes CRM data accidentally.

Skill for Claude Code

Written for Claude Code: when-to-use in frontmatter.

Part of the affinity-crm-sdk-unofficial plugin — 1 skill shipped together

Good fit Use it to initialize synchronous or asynchronous Affinity clients, read CRM records, and write automation that follows the SDK's write-permission rules.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/yaniv-golan/affinity-sdk/affinity-python-sdk
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.

Any agent
npx skills add yaniv-golan/affinity-sdk --skill affinity-python-sdk
Clone the repo
git clone --depth 1 https://github.com/yaniv-golan/affinity-sdk

Made for: Claude Code.

Or install affinity-crm-sdk-unofficial, the plugin that ships this one along with the rest of its 1 skill.

Its marketplace also offers this one on its own, as the plugin affinity-crm-sdk-unofficial — /plugin install affinity-crm-sdk-unofficial after adding the marketplace above.

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 affinity-python-sdk

README.md
[![agentmods](https://agentmods.dev/badge/skills/yaniv-golan/affinity-sdk/affinity-python-sdk/github.svg)](https://agentmods.dev/skills/yaniv-golan/affinity-sdk/affinity-python-sdk)
Your own site
<a href="https://agentmods.dev/skills/yaniv-golan/affinity-sdk/affinity-python-sdk"><img src="https://agentmods.dev/badge/skills/yaniv-golan/affinity-sdk/affinity-python-sdk/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 affinity-python-sdk

Your own site · 80×15
<a href="https://agentmods.dev/skills/yaniv-golan/affinity-sdk/affinity-python-sdk"><img src="https://agentmods.dev/badge/skills/yaniv-golan/affinity-sdk/affinity-python-sdk.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,842 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.00020 $0.04842
Opus 5.5 $0.00008 $0.01937
Sonnet 5.5 $0.00004 $0.00968
Haiku 4.5 $0.00002 $0.00484

Measured 3d ago against content hash 0489c3f80101, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

affinity-python-sdk 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 3d 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.

plugins/affinity-sdk/.claude-plugin/skills/affinity-python-sdk/SKILL.md · 506 lines

How it starts

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

Affinity Python SDK

IMPORTANT: Write Operations Require Explicit User Request

Always use read-only mode by default. Only allow writes when the user explicitly requests data modification.

from affinity.policies import Policies, WritePolicy

# DEFAULT: Read-only mode (prevents accidental data modification)
with Affinity.from_env(policies=Policies(write=WritePolicy.DENY)) as client:
    ...  # Write operations will raise WriteNotAllowedError

# ONLY when user explicitly approves writes:
with Affinity.from_env() as client:
    ...

Installation

# SDK only (Python API wrapper)
pip install affinity-sdk

# SDK with .env file support
pip install "affinity-sdk[dotenv]"

Client Initialization

from affinity import Affinity, AsyncAffinity
from affinity.policies import Policies, WritePolicy

# RECOMMENDED: Read-only with .env file
with Affinity.from_env(load_dotenv=True, policies=Policies(write=WritePolicy.DENY)) as client:
    me = client.whoami()
    companies = client.companies.all()

# Async client
async with AsyncAffinity.from_env(policies=Policies(write=WritePolicy.DENY)) as client:
    companies = await client.companies.all()

API versions

Affinity versions its V2 API by date (2024-01-01, 2026-07-15, 2026-09-17, or current). Unpinned, each request uses the API key's default version, and calls that need a newer one (relationships, company/person field writes, notes per company) send it themselves. Pin when you need consistent response shapes:

client = Affinity.from_env(affinity_api_version="2026-09-17")
client.affinity_api_versions_seen        # versions that answered, e.g. frozenset({"2026-09-17"})

A pin older than a call needs raises ApiVersionTooOldError; a version Affinity rejects raises UnsupportedApiVersionError (both from affinity.exceptions). There is no silent fallback.

Multi-Source Tasks: Output Only the Summary

When a task combines data from multiple Affinity sources (e.g., person + interactions + list entries), fetch everything in one script and print only the relevant summary. Never dump raw model_dump_json() — it floods the conversation with hundreds of lines the agent must parse just to extract a few facts.

Read the full file on GitHub · 506 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 3d ago Changed · +43 lines 0489c3f80101
  2. 5d ago Changed 2ad1f1459ed3
  3. 6d ago Changed · +42 lines 08c9410fcf70
  4. 9d ago Changed · +8 lines 2e4ab83f805f
  5. 1mo ago First seen · 413 lines · 20 tokens per session scan A 46ca719ee1b3

Subscribe to this mod's changes

affinity-python-sdk is a skill published in the GitHub repository yaniv-golan/affinity-sdk (0 stars, last pushed 3d ago), licensed MIT. It adds 20 tokens to every session and 4,842 once invoked, about $0.0001 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

Other skills, from other repositories

fastapi

Use when building, reviewing, testing, securing or shipping a FastAPI / async Python service — routers, Pydantic v2 schemas, dependency injection, async SQLAlchemy 2.0, OAuth2/JWT, ASGITransport tests, production wiring. NOT language-level Python or packaging (that is python), NOT engine-level SQL (that is…

ericrisco/rsc-harness · 94 tokens

pytdbot

Write Telegram bots and userbots with Pytdbot (async TDLib wrapper with high-level helpers; not the Telegram Bot API). Use when the user works with Pytdbot, TDLib, or pytdbot.Client.

pytdbot/client · 49 tokens

cloudflare-workers-multi-lang

Multi-language Workers development with Rust, Python, and WebAssembly. Use when building Workers in languages other than JavaScript/TypeScript, or when integrating WASM modules for performance-critical code.

secondsky/claude-skills · 45 tokens

functions-development

Build serverless Go or Python functions for Falcon Foundry apps. TRIGGER when user asks to "create a function", "write a serverless function", "build backend logic", runs foundry functions create, or needs help with FDK handler patterns, function testing, or collection integration from functions. Also TRIGGER when…

CrowdStrike/foundry-skills · 195 tokens

fastapi-expert

Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.

personamanagmentlayer/pcl · 49 tokens

python-services

Python patterns for CLI tools, async parallelism, and backend services. Use when building CLI apps, async/parallel Python, FastAPI services, background jobs, or configuring Python project tooling (uv, ruff, ty).

iliaal/whetstone · 48 tokens