用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/tomes --skill library-implementer-python命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
> Use when this capability is needed.
Use when writing kernel, account, or note MASM code that reads from or writes to the advice provider (advice stack / advice map) — validate advice data.
Use when writing a Rust test that exercises a failure path or a MASM test that expects a `panic` / `assert` — assert on the specific expected error variant or error code.
基于 SOC 职业分类
正在显示 SKILL.md
| name | library-implementer-python |
| description | | Use when this capability is needed. |
You are a Python library implementer. Your role is to create well-structured Python library modules with reusable functions following the project's layer architecture.
After implementing any library module, run the layer dependency checker to verify architecture compliance:
python scripts/layer_checker.py <library_dir>
Example:
python scripts/layer_checker.py skills/_shared/python
Passing output: All layer dependencies valid. No violations found.
If violations are found: The script reports which files import from disallowed layers. Fix all violations before marking the task complete — Layer N can only import from Layer < N.
lib/
├── __init__.py
├── layer0/ # Zero dependencies (foundation)
│ ├── __init__.py
│ ├── exit_codes.py # Exit code constants
│ ├── colors.py # Color output utilities
│ └── constants.py # Application constants
├── layer1/ # Depends on Layer 0 only
│ ├── __init__.py
│ ├── logging.py # Audit trail logging
│ ├── error_json.py # Standardized error JSON output
│ ├── config.py # Configuration management
│ ├── file_ops.py # Atomic file operations
│ └── output_format.py # JSON/human output formatting
├── layer2/ # Depends on Layer 0-1
│ ├── __init__.py
│ ├── validation.py # Input validation functions
│ └── task_ops.py # Task operations
└── layer3/ # Depends on Layer 0-2
├── __init__.py
├── migrate.py # Schema migration
├── backup.py # Backup operations
├── doctor.py # Diagnostic utilities
└── hierarchy_unified.py # Unified task hierarchy
| Layer | Can Import | Cannot Import |
|---|---|---|
| Layer 0 | None (foundation) | 1, 2, 3 |
| Layer 1 | Layer 0 | 2, 3 |
| Layer 2 | Layer 0, 1 | 3 |
| Layer 3 | Layer 0, 1, 2 | - |
CRITICAL: Never create circular dependencies. Always verify imports follow layer rules.
"""
lib/layer{N}/{module_name}.py - Brief description of module purpose.
This module provides:
- function_one: Brief description
- function_two: Brief description
- ClassName: Brief description
Example:
from lib.layer{N}.{module_name} import function_one
result = function_one(arg1, arg2)
"""
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Optional
# Layer imports (verify layer rules!)
from lib.layer0.exit_codes import EXIT_SUCCESS, EXIT_ERROR
from lib.layer0.constants import DEFAULT_ENCODING
# ==============================================================================
# CONSTANTS
# ==============================================================================
MODULE_CONSTANT: str = "value"
"""Brief description of the constant."""
# ==============================================================================
# EXCEPTIONS
# ==============================================================================
class ModuleError(Exception):
"""Base exception for this module."""
pass
class SpecificError(ModuleError):
"""Raised when specific condition occurs."""
pass
# ==============================================================================
# DATA CLASSES
# ==============================================================================
:
success:
message:
data: [[, ]] =
() -> ResultData:
required_arg:
ValueError()
ResultData(
success=,
message=,
data={: required_arg},
)
() -> :
value.strip().lower()
:
() -> :
.attribute_one: = value
.attribute_two: =
() -> :
# Layer 1 module importing from Layer 0
from lib.layer0.exit_codes import EXIT_SUCCESS, EXIT_ERROR
from lib.layer0.colors import colorize
# Layer 2 module importing from Layer 0 and 1
from lib.layer0.constants import DEFAULT_ENCODING
from lib.layer1.logging import log_action
from lib.layer1.file_ops import atomic_write
# Layer 3 module importing from Layer 0, 1, and 2
from lib.layer0.exit_codes import EXIT_SUCCESS
from lib.layer1.config import load_config
from lib.layer2.validation import validate_task_id
# WRONG: Layer 1 importing from Layer 2
from lib.layer2.validation import validate # Violates layer rules!
# WRONG: Circular import
# In lib/layer1/a.py:
from lib.layer1.b import function_b
# In lib/layer1/b.py:
from lib.layer1.a import function_a # Circular!
from pathlib import Path
from tempfile import NamedTemporaryFile
import shutil
def atomic_write(path: Path, content: str, encoding: str = "utf-8") -> None:
"""Write file atomically using temp file + rename pattern.
Args:
path: Target file path.
content: Content to write.
encoding: File encoding. Defaults to "utf-8".
Raises:
OSError: If write operation fails.
"""
path = Path(path)
path.parent.mkdir(parents=True, exist_ok=True)
# Write to temp file in same directory (for atomic rename)
with NamedTemporaryFile(
mode="w",
dir=path.parent,
delete=False,
encoding=encoding,
suffix=".tmp",
) as tmp:
tmp.write(content)
tmp_path = Path(tmp.name)
# Atomic rename
shutil.move(str(tmp_path), str(path))
from lib.layer1.error_json import emit_error
def safe_operation(file_path: Path) -> ResultData:
"""Perform operation with proper error handling.
Args:
file_path: Path to process.
Returns:
ResultData with operation outcome.
"""
# Check preconditions
if not file_path.exists():
return ResultData(
success=False,
message=f"File not found: {file_path}",
)
try:
content = file_path.read_text()
# Process content...
return ResultData(success=True, message="Success")
except PermissionError as e:
return ResultData(
success=False,
message=f"Permission denied: {file_path}",
data={"error": str(e)},
)
except Exception as e:
# Log unexpected errors
return ResultData(
success=False,
message=f"Unexpected error: {e}",
data={"error_type": type(e).__name__},
)
After creating a module, ALWAYS verify syntax:
python -m py_compile lib/layer{N}/{module_name}.py
@_shared/templates/skill-boilerplate.md#task-integration
TaskGetTaskUpdate (status: in_progress) - skip if orchestrator already setpython -m py_compile lib/layer{N}/{module}.py{{MANIFEST_PATH}}TaskUpdate (status: completed)@_shared/templates/skill-boilerplate.md#subagent-protocol
python -m py_compile{{MANIFEST_PATH}}@_shared/templates/skill-boilerplate.md#manifest-entry
Library-specific fields:
{"id":"lib-{{MODULE}}-{{DATE}}","file":"{{DATE}}_lib-{{MODULE}}.md","title":"Library: {{MODULE}}","date":"{{DATE}}","status":"complete","topics":["library","python","layer{{N}}","{{DOMAIN}}"],"key_findings":["Created lib/layer{{N}}/{{MODULE}}.py with N functions","Functions: function1, function2, function3","Layer: {{N}} (imports from layers 0-{{N-1}})","Type hints: complete","Syntax check passed"],"actionable":false,"needs_followup":["{{TEST_TASK_IDS}}"]
@_shared/templates/skill-boilerplate.md#completion-checklist
Library-specific items:
python -m py_compile)@_shared/templates/anti-patterns.md#implementation-anti-patterns
DO NOT:
Any type when a specific type is known__init__.py* from modulesdef f(x=[]))except: clausesSource: addfox/addfox — distributed by TomeVault.