Welcome, AI Coding Agents (agy, Claude Code, GitHub Copilot, etc.)! This document serves as your central instruction entry point. Please read this file and the referenced skills before making any modifications to the codebase.
aloha-python is a modern project template (boilerplate) and a versatile utility library (aloha package) designed to build robust, containerized microservices in Python.
src/: Application-specific codebase, configuration resources, and tests.src/resource/config/: Configuration files (main.conf, settings, profiles).src/tests/: Unit and integration tests.
pkg/: Corealohautility library package source code.tool/: Helper scripts, build files, and Docker/Docker Compose configs for local CI/CD.doc/: Documentation files and AI Agent Skills.doc/skill: The folder to store all project skill files -- all other agent-specific skill folders (e.g.:.claude/skills,.agent/skills) point to this folder using symlinks.
notebook/: Jupyter notebooks for interactive analysis..agents/: Local customization folder for AI agents containing theskillssymlink setup.
When writing code or configurations for this project, you MUST strictly adhere to the following rules:
- Primary Type/First-Class Identity Prefix: Place the variable's type, role, or primary characteristics first in its name.
- Correct:
name_service,port_service,svc_ingress,cfg_postgres,db_mysql. - Incorrect:
service_name,service_port,ingress_service,postgres_config,mysql_db.
- Correct:
- Logger Naming: Use lowercase with underscores for logger names, e.g.,
db_sync,api_router. - Import Conventions: Use relative imports if possible, especially inside a package.
- HOCON Configuration: Always use HOCON configuration via
aloha.config(SETTINGSobject). Maintain configurations in modular files and import them using the HOCONincludedirective inmain.conf. - No Hardcoded Credentials: Never write plaintext passwords or secrets in configuration files. Configure secrets to resolve dynamically at runtime using the
PasswordVault.
- Safe Multi-Process Logging: Do not instantiate default Python
FileHandlerinside concurrent or multi-process tasks. Usealoha.logger.LOGor named loggers fromget_logger()to ensure safe concurrent log writing.
- Framework: Use
pytestfor all unit and integration testing. - Harness: Subclass
UnitTestCaseorServiceTestCasefromaloha.testingto leverage pre-configured settings, DB connections, and loggers.
We have defined explicit skills to guide specific development tasks. Refer to the corresponding instruction files before editing relevant code:
- Aloha Python Skill
- Covers Python naming standards, sub-modules usage (
aloha.config,aloha.logger,aloha.encrypt,aloha.db,aloha.testing), and the Cython binary compilation process.
- Covers Python naming standards, sub-modules usage (
- Aloha CI/CD & Scaffolding Skill
- Covers project structure layout, local containerized development environments via
./tool/cicd/run-dev.sh, user-specific port calculations, and production Docker builds.
- Covers project structure layout, local containerized development environments via
Note: It is always advised to develop/debug/test code inside a container environment by using the method specified in Local Container Lifecycle.
To execute scripts, run tests, or compile code, work within the containerized local development environment:
Management is driven by ./tool/cicd/run-dev.sh:
# Start the development container in the background
./tool/cicd/run-dev.sh up
# Open an interactive shell inside the container
./tool/cicd/run-dev.sh enter
# Stop the development container
./tool/cicd/run-dev.sh downNote
The helper script dynamically assigns PORT_APP and PORT_WEB based on your system UID to prevent port collisions on shared servers.
To run application entry points, use the generic module runner:
cd src
# Execute within the dev container
python3 main.py <module_path>.<function_name>
# Example
python3 main.py app_common.mainRun tests from the root directory inside the container terminal:
cd src
# Run pytest on application source code
pytest ./
# Run tests and output test coverage
pytest --cov=./ ./To compile code using Cython and build production images:
# Source tool utilities and build the Docker image
source tool/tool.sh
build_image app_common latest src/app-demo.DockerfileThis configuration allows AI coding assistants to load this project's custom definitions automatically.
- Config file:
.agents/skills - Path mapping: Pointing to
../doc/skills. Enablescodex,claude,agy, etc. to resolve all workspace-scoped skills defined underdoc/skills/.