Coding
PromptBeginner5 minmarkdown
Nano Banana Pro
Agent skill for nano-banana-pro
6
- All comments and docstrings must be written in clear, concise English
Sign in to like and favorite skills
Good:
# Initialize cache for 60 seconds self.cache_ttl = 60
Bad:
# 初始化缓存 60 秒 - FORBIDDEN # データキャッシュ60秒 - FORBIDDEN
backend/consts/const.pyos.getenv() or os.environ.get() calls outside of const.pysdk/) should never read environment variables directly - accept configuration via parametersbackend/services/) read from consts.const and pass config to SDKbackend/apps/) read from consts.const and pass through to services/SDKGood:
# backend/consts/const.py APPID = os.getenv("APPID", "") TOKEN = os.getenv("TOKEN", "") # other modules from consts.const import APPID, TOKEN
Bad:
# direct calls in other modules import os appid = os.getenv("APPID") token = os.environ.get("TOKEN")
backend/apps/**/*.py)Purpose: HTTP boundary for the backend - parse/validate input, call services, map domain errors to HTTP
Responsibilities:
HTTPException with proper status codesJSONResponse(status_code=HTTPStatus.OK, content=payload) on successRouting and URL Design:
"/agent", "/memory")"/agents", "/memories")"/agents/{agent_id}"HTTP Methods:
Authorization:
authorization: Optional[str] = Header(None)utils.auth_utils (e.g., get_current_user_id)Exception Mapping:
UnauthorizedError → 401 UNAUTHORIZEDLimitExceededError → 429 TOO_MANY_REQUESTSCorrect Example:
from http import HTTPStatus import logging from fastapi import APIRouter, HTTPException from starlette.responses import JSONResponse from consts.exceptions import LimitExceededError, AgentRunException from services.agent_service import run_agent logger = logging.getLogger(__name__) router = APIRouter() @router.post("/agent/run") def run_agent_endpoint(payload: dict): try: result = run_agent(payload) return JSONResponse(status_code=HTTPStatus.OK, content=result) except LimitExceededError as exc: raise HTTPException(status_code=HTTPStatus.TOO_MANY_REQUESTS, detail=str(exc)) except AgentRunException as exc: raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(exc))
backend/services/**/*.py)Purpose: Implement core business logic orchestration; coordinate repositories/SDKs
Requirements:
backend/consts/exceptions.pyconsts.const)Available Exceptions:
AgentRunException: When agent run failsLimitExceededError: When outer platform calls too frequentlyUnauthorizedError: When user from outer platform is unauthorizedSignatureValidationError: When X-Signature header validation failsMemoryPreparationException: When memory preprocessing/retrieval failsCorrect Example:
from typing import Any, Dict from consts.exceptions import LimitExceededError, AgentRunException, MemoryPreparationException def run_agent(task_payload: Dict[str, Any]) -> Dict[str, Any]: """Run agent core workflow and return domain result dict.""" if _is_rate_limited(task_payload): raise LimitExceededError("Too many requests for this tenant.") try: memory = _prepare_memory(task_payload) except Exception as exc: raise MemoryPreparationException("Failed to prepare memory.") from exc try: result = _execute_core_logic(task_payload, memory) except Exception as exc: raise AgentRunException("Agent execution failed.") from exc return {"status": "ok", "data": result}
backend/consts/const.py.env.exampleos.getenv()/os.environ.get() outside const.pyconsts.const in backend modulesfrom_env() methods from config classeslogger = logging.getLogger(__name__)backend/ ├── apps/ # HTTP API layer (FastAPI endpoints) ├── services/ # Business logic orchestration ├── consts/ │ ├── const.py # Single source of truth for env vars │ └── exceptions.py # Domain exceptions └── utils/ └── auth_utils.py # Authentication utilities sdk/ # Pure configuration-based, no env vars
const.pyfrom_env() in config classesconst.py