pico-ioc
AGENTS.md3 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 code style.
Of the AGENTS.md files we read, the 35,266 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.
- CLAUDE.mdCLAUDE.md
- docs/llms.txtllms.txt
- llms.txtllms.txt
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
- Distinctive: line 57
No docstrings on obvious methods
- Very specific: line 68
Use DictSource for test config, sqlite+aiosqlite:///:memory: for DB tests
- Distinctive: line 83
All changes merged to main, CI green
- Very specific: line 84
Create a GitHub Release with tag vX.Y.Z (e.g., v2.2.3)
- Very specific: line 91
Do not modify _version.py (auto-generated by setuptools-scm)
- Distinctive: line 92
Do not add runtime dependencies (zero-dependency is a core promise)
- Distinctive: line 94
Do not remove or rename public API symbols without a major version bump
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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.
Files
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 docsProject 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, AutoSubscriberMixinKey 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:
MethodInterceptorprotocol withinvoke(ctx, call_next). Applied via@intercepted_by(InterceptorClass) - Configuration:
configuration(DictSource({...}))creates config.@configured(prefix="x", mapping="tree")binds to dataclass - Events:
EventBuswith 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 | Yunion 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 defwhere IO is involved - Exceptions in
exceptions.py, not inline - Typed package:
py.typedmarker present (PEP 561)
Testing
- pytest + pytest-asyncio (mode=strict)
- Tests mirror src structure:
test_container.py,test_scope.py, etc. - Use
DictSourcefor 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: Runstox -e covacross Python 3.11–3.14 matrix. Merges coverage, uploads to Codecov. Triggers on push/PR tomain.docs.yml: Builds MkDocs site. On PR: validates build (--strict). On push tomain: deploys to GitHub Pages.publish-to-pypi.yml: Publishes to PyPI via trusted publishing (OIDC). Triggers on GitHub Release (tag-based).
Release Process
- All changes merged to
main, CI green - Create a GitHub Release with tag
vX.Y.Z(e.g.,v2.2.3) publish-to-pypi.ymltriggers automatically, builds and publishes to PyPI- Version is computed by
setuptools-scmfrom the git tag - 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-iocis 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
| Package | Use it for | Key API |
| pico-boot | App bootstrap + plugin auto-discovery | pico_boot.init(), PICO_BOOT_AUTO_PLUGINS |
| pico-fastapi | HTTP controllers on FastAPI | @controller, @get, @post; container.get(FastAPI) |
| pico-sqlalchemy | Persistence + transactions | @repository, @query, @transactional, AppBase |
| pico-celery | Distributed tasks | @celery, @task, @send_task |
| pico-pydantic | Argument validation AOP | @validate |
| pico-resilience | Retry / circuit breaker / timeout AOP | @retryable, @circuit_breaker, @timeout |
| pico-caching | Method result caching | @cacheable, CacheBackend |
| pico-actuator | Health/info/metrics/refresh endpoints | HealthIndicator, InfoContributor; config prefix actuator |
| pico-otel | OpenTelemetry traces + metrics | OtelSettings; config prefix otel |
| pico-client-auth | JWT validation + RBAC | @requires_role, @requires_scope, @allow_anonymous |
| pico-server-auth | Embeddable auth server (JWT, wallet login, JWKS) | config prefix server_auth |
| pico-scheduling | Interval + cron scheduled methods | @scheduled(every=/cron=); config prefix scheduling |
| pico-httpx | Declarative HTTP clients | @http_client, @get/@post/@put/@delete/@patch; config prefix http |
| pico-data-redis | Redis client + distributed cache backend | injectable redis.Redis, RedisCacheBackend; config prefix redis |
| pico-rabbitmq | RabbitMQ events / fan-out / topic routing | @consumer, @publisher, @publish; config prefix rabbitmq |
| pico-kafka | Kafka streams + consumer groups | @kafka_consumer, @kafka_producer, @produce; config prefix kafka |
| pico-testing | Pytest plugin: isolated containers | make_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;
@retryablegoes on top. - Interceptors'
invokeis sync unless truly async (an asyncinvokebreaks sync methods). - pico-actuator and pico-otel meet at the
prometheus_clientdefault registry:/actuator/metricsserves what pico-otel writes. - pico-client-auth validates tokens that pico-server-auth issues (match
auth_client.issuerwithserver_auth.issuer). - Config hot reload:
container.refresh_config()re-reads tree sources and publishesConfigChanged(pico-ioc >= 2.3.0);POST /actuator/refreshtriggers it over HTTP. - Apps use the factory pattern and import-safe
main.py:uvicorn --factory pkg.main:create_app.
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
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.

