帮助开发者设计可扩展系统,实现运行时插件发现、注册与校验。
该技能材料显示其为开源的提示/设计模式文档,不要求密钥,也未声明任何远程端点;整体风险较低。需注意其内容涉及运行时插件发现与基于配置的插件安装思路,若被具体实现到工具中,供应链与本地数据修改应按常规谨慎处理。
材料明确标注无需密钥或环境变量;未见要求输入 API token、账号凭证或其他敏感认证信息。
未声明任何远程端点,且系统检查项为 prompt-only;从材料可见内容看,不涉及将用户数据发送到外部服务。
作为 Skill 文档本身不执行本机代码。虽然描述中讨论 Python entry points、函数调用评估等插件机制,但这是模式说明而非当前技能直接获得执行权限的证据。
当前材料未声明可读写用户文件或其他资源;仅在示例中提到 `~/.config/my-tool/plugins` 这类配置文件路径,属于说明性的模式内容,不代表该技能实际访问本地数据。
来源为 GitHub 上的开源仓库,具备可审计性,这是明显的降风险因素;但仓库 star 为 0、许可证未声明、维护状态未知,且内容涉及插件安装/发现模式,供应链治理信息不足,建议保留常规留意。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "plugin-discovery-patterns" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/amplifier-bundle-skills/main/skills/plugin-discovery-patterns/SKILL.md 2. 保存为 ~/.claude/skills/plugin-discovery-patterns/SKILL.md 3. 装好后重载技能,告诉我可以用了
请为一个 Python 应用设计插件架构,要求支持通过 entry points 在运行时自动发现插件,并说明目录结构、注册流程、加载顺序、错误处理和示例代码。
得到一套基于 Python entry points 的插件发现方案,包含架构说明与可落地代码示例。
我想用 JSON 或 YAML 维护插件注册表。请帮我设计文件格式、插件元数据字段、加载逻辑、版本兼容策略,以及如何在应用启动时校验并启用插件。
得到文件式插件注册表的结构设计、校验规则和启动加载流程建议。
请为支持多个后端提供者的系统设计统一抽象层,例如不同存储、模型服务或消息队列。要求包含接口定义、适配器模式、输入 schema 校验、扩展新后端的步骤和测试建议。
得到多后端插件化抽象方案,便于统一调用、扩展实现与输入校验。
Problem: You have a tool that needs to support multiple backends (e.g., GitHub vs a self-hosted git server), load user-installed plugins (custom implementations), and validate dynamically-generated forms against schemas that change based on user actions.
Approach: Two-tier plugin discovery (entry points + file-based registry), a frozen dataclass provider abstraction with auto-derived URLs, and schema-driven validation with function-call evaluation.
Pattern proven in production across multiple Python CLI tools and web services.
Plugins are discovered at runtime via importlib.metadata.entry_points():
def load_plugin(name: str) -> object | None:
"""Load a plugin by name via entry_points."""
try:
eps = entry_points(group="my_tool.plugins")
for ep in eps:
if ep.name == name:
plugin_class = ep.load()
return plugin_class()
except Exception:
logger.debug("Failed to discover plugin %r", name, exc_info=True)
return None
But there's a second tier: the file-based registry at ~/.config/my-tool/plugins. This file stores the PEP 508 specs that were used to install each plugin:
def _read_plugins() -> list[str]:
"""Read plugin specs from the config file."""
path = _get_plugins_config_path()
if not path.exists():
return []
lines = path.read_text().splitlines()
return [line.strip() for line in lines if line.strip() and not line.strip().startswith("#")]
Why two tiers? Entry points tell you what's active (installed and importable). The config file tells you what should be installed. Discrepancies (configured but not active) indicate a reinstall is needed.
The plugin list command compares both tiers:
def plugin_list():
configured = _read_plugins()
active_eps = list(entry_points(group="my_tool.plugins"))
active_ep_names = [ep.name for ep in active_eps]
for spec in configured:
pkg_name = _extract_package_name(spec)
is_active = any(pkg_name in ep_name or ep_name in pkg_name
for ep_name in active_ep_names)
if is_active:
print(f" {ok_mark} {spec}")
else:
print(f" {warn_mark} {spec}")
print(f" (configured but not active — run: my-tool upgrade --force)")
Adding a plugin writes to the config file AND reinstalls:
def plugin_add(spec: str):
name = _extract_package_name(spec)
specs = _read_plugins()
# Dedup: replace existing entry with same package name
existing_names = [_extract_package_name(s) for s in specs]
if name in existing_names:
idx = existing_names.index(name)
specs[idx] = spec # allows upgrading a pinned spec
else:
specs.append(spec)
_write_plugins(specs)
_reinstall_with_plugins(specs) # uv tool install --with ...
The _extract_package_name function handles PEP 508 specs:
def _extract_package_name(spec: str) -> str:
"""Extract the bare package name from a PEP 508 spec string.
'my-plugin @ git+https://...' -> 'my-plugin'
'my-pkg>=1.0' -> 'my-pkg'
"""
return re.split(r"\s*[@>=<!~]", spec)[0].strip()
Encapsulate all provider-specific logic behind a single abstraction:
@dataclass(frozen=True)
class ServiceProvider:
"""Provider-agnostic service configuration. Instances are immutable."""
kind: str = "default"
host: str = "api.example.com"
token_env: str = "API_TOKEN"
api_base: str = "" # auto-derived when empty
scheme: str = "https"
…
帮助你调研、规划并并行执行大规模代码变更,让多个代理分别提交 PR。
用多模型视觉能力分析图片内容、提取文字并回答图像相关问题。
帮助开发者设计安全持久的配置与状态文件管理模式,兼顾默认值合并和崩溃恢复。
以资深工程师视角审视架构、遗留重构与工具选型,给出务实建议。
帮助开发与运维设计兼顾本地顺畅和远程安全的认证与 TLS 接入方案。
帮助开发者设计易安装、易扩展且配置分层清晰的 CLI 工具模式。
帮助设计或评估命令行工具与开发者 SDK 的架构、兼容性和使用体验
帮助开发者发现并评估 Laravel 插件,检查健康度与兼容性
帮助设计和评估事件驱动、消息驱动与异步工作流系统架构。
帮助你高效创建、修改、测试与发布 Claude Code 插件的全流程技能
帮助你设计或评估Web服务架构、API模式、扩展性与可靠性问题。
在协作会话中引导你从零创建插件并生成可交付的 .plugin 文件