SkillAgentSearch skills...

code-patterns

Python code style and recurring patterns (config, logging, errors, paths)

Install / Use

npx skills add divar-ir/ai-doc-gen

Installs into whichever agent you are using.

About this skill
📐

Cursor Rules

Cursor IDE rules (v2)

Quality Score

81/100

Supported Platforms

Cursor

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.

Substance
26/30
Structure
16/20
Description
12/15
Adoption
12/20
Freshness
15/15

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 found

Our 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.

SkillScoreStarsUpdatedFormat
code-patterns (this skill)by divar-ir817633mo agoCursor Rules
Agent-Reachby Panniantong10092.6k21d agoCLAUDE.md
headroomby headroomlabs-ai10074.5ktodayCLAUDE.md
ai-job-searchby MadsLorentzen10045.1k1d agoCLAUDE.md
claude-howtoby luongnv8910041.8k6d agoCLAUDE.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.

description: 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 — run uv run ruff format src/ && uv run ruff check src/.
  • Type hints everywhere; pathlib.Path for all file paths (never strings); Pydantic BaseModel for all config/data structures.
  • Naming: snake_case files/functions, PascalCase classes, _private methods, UPPER_SNAKE constants, config classes end in Config.

Configuration

class MyHandlerConfig(BaseHandlerConfig, MyAgentConfig):
    exclude_feature: bool = Field(default=False, description="Exclude feature")  # description feeds CLI --help
  • Every Field needs a description — CLI arguments are generated from it (--exclude-feature, store_true, default None = "not specified").
  • Load order: Pydantic defaults < .ai/config.yaml (dot-notation section keys) < CLI args, merged with merge_dicts().
  • Env vars in src/config.py: required → os.environ["KEY"]; optional → os.getenv("KEY", "default") with int()/float()/str_to_bool() conversion.

Async and concurrency

  • All handler/agent operations are async; handlers implement async def handle(self).
  • Bounded concurrency: use WorkerPool from src/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 with exc_info=True, continue.

Error handling

  • Partial success is acceptable: warn and continue if some agents fail; raise ValueError only 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 like repo_path, token counts.

Files

  • Path arithmetic (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

View on GitHub
GitHub Stars763
CategoryDevelopment
Updated2mo ago
Forks82

Languages

Python

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

No cautions
code-patterns — Cursor Rules: Install & Safety Check | SkillAgent