← Back to list
B. The public API pattern (

manage-architecture
by Row0902
⭐ 0🍴 0📅 Jan 21, 2026
SKILL.md
name: Manage Architecture description: Standards for package structure, module grouping, and correct import strategies.
🏛️ Architecture & Import Management Skill
Context
You are the Chief Architect. Your role is to ensure the codebase remains modular, decoupled, and free of "Import Hell" (circular dependencies).
1. Import Strategy (The "Golden Rules")
A. Absolute vs Relative
- Cross-Package: Use ABSOLUTE imports.
- ✅
from src.core.events import EventBus - ❌
from ...core.events import EventBus
- ✅
- Intra-Package (Siblings): Use RELATIVE imports.
- ✅
from .types import MyType - ❌
from src.services.drive.types import MyType(If you are insrc.services.drive)
- ✅
B. The public API pattern (__init__.py)
Never import "deep" module files from outside the package.
- Bad:
from src.services.drive.search_impl import SearchService - Good:
from src.services.drive import SearchService- (Requires
SearchServiceto be exported insrc/services/drive/__init__.py)
- (Requires
C. Prevention of Circular Imports
- Type Checking Imports: Use
if TYPE_CHECKING:for types that cause cycles.from typing import TYPE_CHECKING if TYPE_CHECKING: from src.services.account import AccountManager - Dependency Injection: If A needs B and B needs A, extract the shared interface to C (Interface Segregation).
2. Structural Integrity (Packaging)
A. Group by Domain (Not Layer)
- Preferred:
src/features/auth/(Contains UI, Logic, Models for Auth). - Allowed:
src/ui/,src/services/(Traditional Layered). - Prohibited:
src/utils.py(The "God File"). Split intosrc/core/utils/date.py,src/core/utils/string.py.
B. Module Size Cap
- Rule: If a file > 300 lines -> ALERT.
- Action: Propose splitting into a sub-package.
src/services/drive.py(500 lines) ->src/services/drive/(folder) containingcore.py,api.py,types.py.
3. Review Protocol
Before approving ANY architectural change:
- Check Imports: Run command
uv run ruff check --select I(Import sorting/validation). - Verify Coupling: Does
src/coreimportsrc/ui? -> FORBIDDEN (Core cannot depend on UI). - Verify Namespace: Are we polluting the namespace? (Avoid
from module import *).
4. Troubleshooting
- "ImportError: attempted relative import...": You ran a file directly (
python file.py). ALWAYS run as module:uv run python -m src.package.file.
Score
Total Score
35/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
○言語
プログラミング言語が設定されている
0/5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon