code-patterns
Python code style and recurring patterns (config, logging, errors, paths)
Install / Use
npx skills add divar-ir/ai-doc-genInstalls into whichever agent you are using.
Cursor Rules
Cursor IDE rules (v2)
Quality Score
Category
Development & EngineeringSupported Platforms
Our assessment of code-patterns
code-patterns scores 81/100 on our quality scale, 3484th of 4,582 Development & Engineering skills we index.
Its Cursor Rules is 2.6 KB long, split into 7 sections with 2 code examples: a solid amount of guidance for an agent.
It has 763 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated about 3 months ago, so code-patterns is actively maintained.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands.
Automated pattern scan on 2026-10-07. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
code-patterns compared with similar skills
All 4 of these similar skills score higher than code-patterns; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| code-patterns (this skill)by divar-ir | 81 | 763 | 3mo ago | Cursor Rules |
| Agent-Reachby Panniantong | 100 | 92.6k | 21d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.5k | today | CLAUDE.md |
| ai-job-searchby MadsLorentzen | 100 | 45.1k | 1d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.8k | 6d ago | CLAUDE.md |
Frequently asked questions
- How do I install code-patterns?
- Run
npx skills add divar-ir/ai-doc-gen. The install tabs above show the steps for each supported agent. - Which AI agents does code-patterns work with?
- It is written for Cursor, as a Cursor Rules file. Other agents that read the same format can often use it too.
- Is code-patterns safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is code-patterns still maintained?
- The repository was last updated about 3 months ago, so code-patterns is actively maintained.
Skill content
View source on GitHubdescription: Python code style and recurring patterns (config, logging, errors, paths) globs:
- "src/**/*.py" alwaysApply: false
Code Patterns
Style
- Ruff: 120-char lines, 4-space indent,
target-version = "py313"; import sorting enabled — runuv run ruff format src/ && uv run ruff check src/. - Type hints everywhere;
pathlib.Pathfor all file paths (never strings); PydanticBaseModelfor all config/data structures. - Naming: snake_case files/functions, PascalCase classes,
_privatemethods, UPPER_SNAKE constants, config classes end inConfig.
Configuration
class MyHandlerConfig(BaseHandlerConfig, MyAgentConfig):
exclude_feature: bool = Field(default=False, description="Exclude feature") # description feeds CLI --help
- Every
Fieldneeds adescription— CLI arguments are generated from it (--exclude-feature, store_true, defaultNone= "not specified"). - Load order: Pydantic defaults <
.ai/config.yaml(dot-notation section keys) < CLI args, merged withmerge_dicts(). - Env vars in
src/config.py: required →os.environ["KEY"]; optional →os.getenv("KEY", "default")withint()/float()/str_to_bool()conversion.
Async and concurrency
- All handler/agent operations are async; handlers implement
async def handle(self). - Bounded concurrency: use
WorkerPoolfromsrc/utils/worker_pool.py(WorkerPool(max_workers=0)= CPU count) for many tasks;asyncio.gather(*tasks, return_exceptions=True)for a fixed small set. - Always isolate errors: check each result with
isinstance(result, Exception), log withexc_info=True, continue.
Error handling
- Partial success is acceptable: warn and continue if some agents fail; raise
ValueErroronly on complete failure. - Guarantee cleanup with try/finally (e.g., cronjob project cleanup).
- Inside agent tools, raise
ModelRetry(from pydantic_ai) for recoverable errors — file not found, permission denied.
Logging and tracing
from utils import Logger
Logger.init(logs_dir) # once per execution, before any use
Logger.info("Agent completed", {"total_tokens": usag…[redacted]}) # structured dict payload
Logger.error("Failed", exc_info=True) # always exc_info=True for errors
- Wrap major operations in OpenTelemetry spans:
tracer.start_as_current_span(...), set attributes likerepo_path, token counts.
Files
Patharithmetic (repo_path / ".ai" / "docs"),mkdir(parents=True, exist_ok=True)before writing,read_text()/write_text().- Replace absolute paths with
.in agent outputs before writing (portability).
Related Skills
Agent-Reach
92.6kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
74.5kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
ai-job-search
45.1kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.8kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
