技能 autonomous-agent-patterns
🤖

autonomous-agent-patterns

安全

构建自主AI智能体

学习经过验证的设计模式,用于创建具有正确工具集成、权限系统和安全控制的自主编码智能体。这对于构建AI驱动开发工具的开发者来说是必不可少的。

支持: Claude Codex Code(CC)
🥉 74 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“autonomous-agent-patterns”。 Show me how to build an agent that can read and edit files with proper permission controls.

预期结果:

A Python implementation showing: 1) FileTool base class with JSON schema, 2) ReadFileTool and EditFileTool implementations, 3) PermissionLevel enum with AUTO/ASK_ONCE/ASK_EACH/NEVER levels, 4) ApprovalManager that checks permission config before executing tools, 5) Example config mapping read_file to AUTO and write_file to ASK_ONCE.

正在使用“autonomous-agent-patterns”。 How do I create a visual agent that can click buttons on web pages by describing them?

预期结果:

A VisualAgent pattern using: 1) BrowserTool with Playwright for screenshot capture, 2) Vision model integration to analyze screenshots, 3) find_and_click method that asks LLM to locate elements by description and return coordinates, 4) Mouse click at detected coordinates. Includes error handling for elements not found.

正在使用“autonomous-agent-patterns”。 Design a checkpoint system for long-running agent tasks.

预期结果:

CheckpointManager class with: 1) save_checkpoint method capturing history, context, workspace state (git status), and metadata, 2) restore_checkpoint to reload state, 3) Uses JSON storage with session IDs, 4) Includes workspace capture via git commands for state tracking.

安全审计

安全
v1 • 2/24/2026

This skill is a reference documentation resource containing code examples for building autonomous agents. All detected patterns (external_commands, network, filesystem, env_access) are documentation examples demonstrating legitimate agent patterns, not actual executable malicious code. The skill does not contain prompt injection attempts or malicious intent. All findings are false positives - the skill is educational content about agent architecture.

1
已扫描文件
764
分析行数
0
发现项
1
审计总数
未发现安全问题
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
100
安全
91
规范符合性

你能构建什么

构建Claude Code扩展

创建使用Claude进行自主代码编辑的VS Code扩展或CLI工具,并配备正确的权限控制。

设计安全的智能体API

为AI智能体框架实现具有权限级别、审批对话框和沙盒化的工具调用API。

为智能体添加浏览器自动化

通过视觉元素检测和自动化,使您的AI智能体能够与Web应用程序交互。

试试这些提示

基础智能体循环
展示如何在Python中实现一个基础的智能体循环,使用LLM来决定何时使用工具以及何时返回最终答案。
权限系统
为AI智能体创建一个权限系统,包含不同级别:安全操作自动批准、中等风险一次性询问、危险命令每次询问、以及禁止操作永不允许。
沙盒化执行
编写一个Python类,在沙盒环境中安全地执行shell命令,限制可运行的命令并将文件系统访问限制在工作目录内。
MCP工具发现
展示如何实现动态MCP服务器连接,发现可用工具并允许根据用户描述在运行时创建新工具。

最佳实践

  • 始终实施权限级别 - 自动批准安全的读取操作,但需要对文件写入和命令执行进行审批
  • 使用沙盒化执行环境来限制可访问的命令和文件系统路径
  • 使用清晰的JSON模式定义工具,以便LLM理解每个工具的功能及其参数

避免

  • 允许无限制的命令执行而没有权限检查或沙盒化
  • 为智能体提供无限上下文而没有适当的上下文管理和大小限制
  • 实现描述模糊的工具,使得工具的功能不明确

常见问题

这个技能可以直接使用还是需要我实现?
这是包含代码示例的参考文档技能。您需要在自己的代码库中实现这些模式。它教您如何构建自主智能体,它本身不是一个可运行的智能体。
哪些AI模型可以使用这些模式?
这些模式适用于任何支持工具调用的LLM,包括Claude、GPT-4和其他模型。这些模式与模型无关。
运行这些智能体模式需要特殊权限吗?
这些模式包含自己的权限系统。您不需要特殊权限来学习或实现它们。该技能本身不执行任何代码。
这些模式会损坏我的系统吗?
这些模式包含沙盒化和权限级别等安全功能。但是,在实现它们时,您需要负责正确的安全配置。始终限制危险命令并限制文件系统访问。
如何开始构建智能体?
从核心智能体架构部分开始,了解思考-决策-行动-观察循环。然后从第2部分实现基础工具。在启用任何危险操作之前,从第3部分添加权限控制。
什么是MCP?它与这些模式有什么关系?
MCP(模型上下文协议)是连接AI智能体与外部工具和数据源的标准。第6部分展示了如何使用MCP实现动态工具发现,允许智能体自动查找和使用工具。

开发者详情

文件结构

📄 SKILL.md