agentleFS
dperezcabreradperezcabrera/pico-skills/.claude/skills/add-repository/SKILL.md

add-repository

Skill4 starsChanged 4 months agoMITView on GitHub

Add a SQLAlchemy entity and repository with pico-sqlalchemy. Use when creating database models, repositories, or adding database queries.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. alimranfakir/Claude_skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository12 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create entity and repository for: $ARGUMENTS

    line 10
  2. Distinctive:

    Read the codebase to understand existing models and patterns, then create the entity and repository.

    line 12

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add Repository

Create entity and repository for: $ARGUMENTS

Read the codebase to understand existing models and patterns, then create the entity and repository.

1. Entity

from sqlalchemy import String, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from pico_sqlalchemy import AppBase

class $ARGUMENTS(AppBase):
    __tablename__ = "<plural_snake_case>"

    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(100))
    active: Mapped[bool] = mapped_column(default=True)

2. Repository with Declarative Queries

from pico_sqlalchemy import repository, query, get_session, SessionManager, Page, PageRequest

@repository(entity=$ARGUMENTS)
class ${ARGUMENTS}Repository:
    def __init__(self, manager: SessionManager):
        self.manager = manager

    async def save(self, entity: $ARGUMENTS) -> $ARGUMENTS:
        session = get_session(self.manager)
        session.add(entity)
        return entity

    @query(expr="id = :id", unique=True)
    async def find_by_id(self, id: int) -> $ARGUMENTS | None:
        ...

    @query(expr="name = :name", unique=True)
    async def find_by_name(self, name: str) -> $ARGUMENTS | None:
        ...

    @query(expr="active = true", paged=True)
    async def find_all_active(self, page: PageRequest) -> Page[$ARGUMENTS]:
        ...

Raw SQL Queries

    @query(sql="SELECT * FROM items WHERE name LIKE :pattern ORDER BY name")
    async def search(self, pattern: str) -> list[$ARGUMENTS]:
        ...

3. Service Layer

from pico_ioc import component
from pico_sqlalchemy import transactional

@component
class ${ARGUMENTS}Service:
    def __init__(self, repo: ${ARGUMENTS}Repository):
        self.repo = repo

    @transactional
    async def create(self, name: str) -> $ARGUMENTS:
        entity = $ARGUMENTS(name=name)
        return await self.repo.save(entity)

    @transactional(read_only=True)
    async def get(self, id: int) -> $ARGUMENTS:
        item = await self.repo.find_by_id(id)
        if not item:
            raise ValueError(f"$ARGUMENTS {id} not found")
        return item

Transaction Propagation

ModeBehavior
REQUIREDJoin existing or create new (default)
REQUIRES_NEWAlways start a fresh transaction
SUPPORTSJoin if exists, otherwise non-transactional
MANDATORYMust have active transaction, else error
NOT_SUPPORTEDSuspend transaction, run without
NEVERError if transaction is active

Note: REQUIRES_NEW only opens a new transaction when the method is called on another injected component — AOP interception does not apply to self.method() (self-invocation), exactly like Spring.

Transaction-scoped components (Unit-of-Work)

A @component(scope="transaction") lives exactly one transaction: one shared instance across the whole call tree of a transaction, released (running its @cleanup hooks) on commit/rollback. Useful for a per-transaction identity-map, a domain-event collector flushed on commit, or per-transaction caches. REQUIRES_NEW gets its own instance; resolving one outside any transaction raises ScopeError.

Checklist

  • Entity with correct column types and constraints
  • Repository with SessionManager injected via constructor
  • @query methods for common lookups
  • Service layer with @transactional for business operations
  • Indexes on frequently queried columns

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.