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

add-component

Skill4 starsChanged 4 months agoMITView on GitHub

Add a new pico-ioc component with dependency injection. Use when creating services, factories, interceptors, event subscribers, or configured settings.

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 3

    Distinctive

    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 a component: $ARGUMENTS

    line 10
  2. Distinctive:

    Read the codebase to understand existing patterns, then create the component following these templates.

    line 12
  3. Distinctive:

    Use when the component needs complex construction or wraps an external library:

    line 38

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “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 Pico-IoC Component

Create a component: $ARGUMENTS

Read the codebase to understand existing patterns, then create the component following these templates.

Basic Component

from pico_ioc import component

@component
class $ARGUMENTS:
    def __init__(self, dependency: SomeDependency):
        self.dependency = dependency

    async def do_something(self) -> Result:
        return await self.dependency.process()

With Scope

@component(scope="singleton")  # singleton | prototype | request
class $ARGUMENTS:
    ...

Factory Provider

Use when the component needs complex construction or wraps an external library:

from pico_ioc import factory, provides

@factory
class InfraFactory:
    @provides(ExternalClient, scope="singleton")
    def create_client(self, settings: AppSettings) -> ExternalClient:
        return ExternalClient(url=settings.url, timeout=settings.timeout)

AOP Interceptor

from pico_ioc import component, MethodInterceptor, MethodCtx

@component(scope="singleton")
class LoggingInterceptor(MethodInterceptor):
    async def invoke(self, ctx: MethodCtx, call_next):
        print(f"Calling {ctx.method_name}")
        result = await call_next(ctx)
        return result

Apply with @intercepted_by(LoggingInterceptor) on methods.

Configuration Dataclass

from dataclasses import dataclass
from pico_ioc import configured

@configured(prefix="section_name")
@dataclass
class MySettings:
    host: str = "localhost"
    port: int = 8080
    debug: bool = False

Reads from YAML:

section_name:
  host: "0.0.0.0"
  port: 9090

Event Subscriber

from pico_ioc import component, subscribe, Event

class OrderPlacedEvent(Event):
    def __init__(self, order_id: int):
        self.order_id = order_id

@component
class NotificationService:
    @subscribe(OrderPlacedEvent)
    async def on_order_placed(self, event: OrderPlacedEvent):
        await self.notify(event.order_id)

Checklist

  • Scope matches lifecycle needs (singleton for stateless, prototype for stateful, request for per-request)
  • Dependencies injected via constructor type hints
  • Protocol/interface defined if multiple implementations exist
  • Component is testable with mocked dependencies

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.