agentleFS
dperezcabreradperezcabrera/pico-ioc/AGENTS.md

pico-ioc

AGENTS.md2 starsChanged 10 months agoMITView on GitHub

Lightweight, async-native dependency injection container for Python 3.11+. Zero runtime dependencies.

  • Pipes a download into a shell
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    No docstrings on obvious methods

    line 57
  2. Very specific:

    Use DictSource for test config, sqlite+aiosqlite:///:memory: for DB tests

    line 68
  3. Distinctive:

    All changes merged to main, CI green

    line 83
  4. Very specific:

    Create a GitHub Release with tag vX.Y.Z (e.g., v2.2.3)

    line 84
  5. Very specific:

    Do not modify _version.py (auto-generated by setuptools-scm)

    line 91
  6. Distinctive:

    Do not add runtime dependencies (zero-dependency is a core promise)

    line 92
  7. Distinctive:

    Do not remove or rename public API symbols without a major version bump

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md 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
AGENTS.md

pico-ioc

Lightweight, async-native dependency injection container for Python 3.11+. Zero runtime dependencies.

Commands

pip install -e ".[test]"          # Install in dev mode
pytest tests/ -v                  # Run tests
pytest --cov=pico_ioc --cov-report=term-missing tests/  # Coverage
tox                               # Full matrix (3.11-3.14)
ruff check src/ tests/            # Lint
ruff format --check src/ tests/   # Format check
mkdocs serve -f mkdocs.yml        # Local docs

Project Structure

src/pico_ioc/
  __init__.py              # Public API — re-exports 60 symbols via __all__
  constants.py             # PICO_META, PICO_INFRA, PICO_NAME, PICO_KEY, scope names
  exceptions.py            # Exception hierarchy rooted in PicoError
  decorators.py            # @component, @factory, @provides, @configured, @intercepted_by, metadata helpers
  api.py                   # High-level API: factory(), provides(), configure(), cleanup(), init()
  container.py             # PicoContainer — core DI container, wiring, resolution, lifecycle
  locator.py               # ComponentLocator — provider lookup registry, multi-binding
  registrar.py             # Registrar — scans decorated classes and registers providers
  component_scanner.py     # ComponentScanner — recursive package import + component discovery
  scope.py                 # ScopeProtocol, ScopeManager, ContextVarScope, ScopedCaches
  _providers.py            # ProviderMetadata, DeferredProvider, Provider, ComponentFactory (private module; symbols re-exported from pico_ioc)
  dependency_validator.py  # Startup validation: cycle detection, missing providers
  provider_selector.py     # ProviderSelector — config-driven multi-provider resolution
  aop.py                   # AOP: MethodCtx, MethodInterceptor, UnifiedComponentProxy, health()
  config_builder.py        # configuration(), ContextConfig, EnvSource, FileSource, FlatDictSource, Value
  config_runtime.py        # Runtime config: JsonTreeSource, YamlTreeSource, DictSource, Discriminator, Value
  config_registrar.py      # ConfigurationManager — registers @configured dataclasses as providers
  analysis.py              # DependencyRequest, analyze_callable_dependencies — introspection
  event_bus.py             # EventBus, @subscribe, ExecPolicy, ErrorPolicy, AutoSubscriberMixin

Key Concepts

  • Decorators: @component, @factory, @provides, @configured, @intercepted_by, @subscribe
  • Internal attributes: _pico_infra (str: "component"/"configured"/"factory"/"provides"), _pico_meta (dict: scope, qualifier, etc.), _pico_name, _pico_key
  • Scopes: singleton, prototype, request, session, websocket, transaction (built-in via ContextVarScope)
  • Resolution: Constructor injection by type hint. Lists via qualifier. container.get() (sync) / container.aget() (async)
  • AOP: MethodInterceptor protocol with invoke(ctx, call_next). Applied via @intercepted_by(InterceptorClass)
  • Configuration: configuration(DictSource({...})) creates config. @configured(prefix="x", mapping="tree") binds to dataclass
  • Events: EventBus with sync/async dispatch, ExecPolicy (INLINE/THREADPOOL/TASK), ErrorPolicy, @subscribe
  • Entry point: init(modules=[...], config=cfg) bootstraps container

Code Style

  • Python 3.11+ (type hints with X | Y union syntax preferred)
  • Linting: ruff check (rules: E, F, I, UP). Formatting: ruff format
  • No docstrings on obvious methods
  • Private attributes prefixed with _
  • Internal pico attributes: _pico_* (never __dunder__)
  • Async-first: prefer async def where IO is involved
  • Exceptions in exceptions.py, not inline
  • Typed package: py.typed marker present (PEP 561)

Testing

  • pytest + pytest-asyncio (mode=strict)
  • Tests mirror src structure: test_container.py, test_scope.py, etc.
  • Use DictSource for test config, sqlite+aiosqlite:///:memory: for DB tests
  • No conftest.py — fixtures are local to each test file
  • Target: >95% coverage
  • Coverage config: .coveragerc (branch=True, omit _version.py)

CI/CD

Three GitHub Actions workflows:

  • ci.yml: Runs tox -e cov across Python 3.11–3.14 matrix. Merges coverage, uploads to Codecov. Triggers on push/PR to main.
  • docs.yml: Builds MkDocs site. On PR: validates build (--strict). On push to main: deploys to GitHub Pages.
  • publish-to-pypi.yml: Publishes to PyPI via trusted publishing (OIDC). Triggers on GitHub Release (tag-based).

Release Process

  1. All changes merged to main, CI green
  2. Create a GitHub Release with tag vX.Y.Z (e.g., v2.2.3)
  3. publish-to-pypi.yml triggers automatically, builds and publishes to PyPI
  4. Version is computed by setuptools-scm from the git tag
  5. NEVER change version_scheme — must remain "post-release" (see CLAUDE.md)

Boundaries

  • Do not modify _version.py (auto-generated by setuptools-scm)
  • Do not add runtime dependencies (zero-dependency is a core promise)
  • pico-ioc is the foundation — no circular deps with other pico-* packages
  • Do not remove or rename public API symbols without a major version bump

Pico Ecosystem

pico-ioc is the foundation. Every module below builds on it, is installed with pip install <name>, and — in a pico-boot app — activates by just being installed (auto-discovery via the pico_boot.modules entry point; no code changes). Without pico-boot, list the module in init(modules=[...]).

Runtime modules

PackageUse it forKey API
pico-bootApp bootstrap + plugin auto-discoverypico_boot.init(), PICO_BOOT_AUTO_PLUGINS
pico-fastapiHTTP controllers on FastAPI@controller, @get, @post; container.get(FastAPI)
pico-sqlalchemyPersistence + transactions@repository, @query, @transactional, AppBase
pico-celeryDistributed tasks@celery, @task, @send_task
pico-pydanticArgument validation AOP@validate
pico-resilienceRetry / circuit breaker / timeout AOP@retryable, @circuit_breaker, @timeout
pico-cachingMethod result caching@cacheable, CacheBackend
pico-actuatorHealth/info/metrics/refresh endpointsHealthIndicator, InfoContributor; config prefix actuator
pico-otelOpenTelemetry traces + metricsOtelSettings; config prefix otel
pico-client-authJWT validation + RBAC@requires_role, @requires_scope, @allow_anonymous
pico-server-authEmbeddable auth server (JWT, wallet login, JWKS)config prefix server_auth
pico-schedulingInterval + cron scheduled methods@scheduled(every=/cron=); config prefix scheduling
pico-httpxDeclarative HTTP clients@http_client, @get/@post/@put/@delete/@patch; config prefix http
pico-data-redisRedis client + distributed cache backendinjectable redis.Redis, RedisCacheBackend; config prefix redis
pico-rabbitmqRabbitMQ events / fan-out / topic routing@consumer, @publisher, @publish; config prefix rabbitmq
pico-kafkaKafka streams + consumer groups@kafka_consumer, @kafka_producer, @produce; config prefix kafka
pico-testingPytest plugin: isolated containersmake_container fixture, @pytest.mark.pico_auto_plugins

Tooling and companions

  • pico-initializer — scaffolds projects/modules (web UI + node cli.js); the source of truth for a correct app skeleton.
  • pico-skills — installable AI coding skills: curl -sL https://raw.githubusercontent.com/dperezcabrera/pico-skills/main/install.sh | bash
  • pico-learn — interactive browser lessons (pyodide): https://dperezcabrera.github.io/pico-learn/
  • pico-auth — standalone deployable auth server application (not a module; embed pico-server-auth instead if you need auth inside your app).

Composition rules that matter when using them

  • AOP decorators combine on one method; @retryable goes on top.
  • Interceptors' invoke is sync unless truly async (an async invoke breaks sync methods).
  • pico-actuator and pico-otel meet at the prometheus_client default registry: /actuator/metrics serves what pico-otel writes.
  • pico-client-auth validates tokens that pico-server-auth issues (match auth_client.issuer with server_auth.issuer).
  • Config hot reload: container.refresh_config() re-reads tree sources and publishes ConfigChanged (pico-ioc >= 2.3.0); POST /actuator/refresh triggers it over HTTP.
  • Apps use the factory pattern and import-safe main.py: uvicorn --factory pkg.main:create_app.

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.