affinity-python-sdk

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 CodeCodex

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.

agentmods
npx agentmods add skills/yaniv-golan/affinity-sdk/affinity-python-sdk
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, Codex.

Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,368 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00020 $0.03368
Opus 5 $0.00010 $0.01684
Sonnet 5 $0.00004 $0.00674
Haiku 4.5 $0.00002 $0.00337

Measured yesterday against content hash 46ca719ee1b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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 · 413 lines

How it starts

The opening of the file, as written. The whole thing — 413 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()

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.

Do this when: combining entity details with interactions, cross-referencing list entries with entities, generating reports from multiple queries.

A single SDK call is fine when: fetching one entity, listing one page of results, or performing a single write.

Bad: dumping raw models

person = client.persons.get(PersonId(123))
print(person.model_dump_json(indent=2))  # 200+ lines of raw JSON

Good: extract and print only what's needed

Read the full file on GitHub · 413 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. yesterday 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 1mo ago), licensed MIT. It adds 20 tokens to every session and 3,368 once invoked, about $0.0001 per session on Opus 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

liter-llm

Universal LLM API client for 165 providers with native bindings for 14 languages. Use when writing code that calls LLM APIs via liter-llm in Python, TypeScript, Rust, Go, Java, C#, Ruby, PHP, Elixir, WASM, or C, when running the OpenAI-compatible proxy, or when calling LLMs through the MCP server. Covers chat…

xberg-io/liter-llm · 117 tokens

wiki-cleanup

Review and clean up the human-facing tik4net GitHub wiki (the clone next to the repo) page by page, so that it does not scare off a newcomer and still answers a returning reader's technical question. Use when the user asks to review/audit/clean/tidy the wiki or a wiki page, to check wiki examples against the code, to…

danikf/tik4net · 174 tokens

mikrotik-tests

Skill for working with tik4net integration tests against a live MikroTik router. Use this skill whenever the user wants to: run tests (single transport or the full matrix), create a new test class/method, inspect or clean router state, understand why a test was skipped (Inconclusive), debug failures, analyze orphan…

danikf/tik4net · 110 tokens

winbox-native-dev

Develop and extend the tik4net WinBoxNative (structured M2) transport: add a new path→handler mapping, a new field UI-type encoder/decoder, a singleton/list/range/enum/reference field, an action verb or streaming monitor — by cross-referencing the three sources of truth (the version-matched .jg catalog, the webfig…

danikf/tik4net · 211 tokens

calling-llms

Use when sending chat completions through liter-llm and routing to a specific provider via the provider/model prefix. Covers the chat call shape, provider routing, modelhint, message roles, and error categories.

xberg-io/liter-llm · 49 tokens

embeddings-and-search

Use when generating embeddings, calling the 12 web-search providers, or running OCR over documents with the 4 OCR providers through liter-llm. Covers embed, search, and ocr methods plus reranking.

xberg-io/liter-llm · 48 tokens