python-agent-development
БесплатноБез исполняемых скриптовНе проверенPython Agent 开发规范(Windows wxauto v4),包括项目结构、模块化、wxauto 使用、IPC 集成、错误处理、测试和部署。
от majiayu000★ 31 звезда на GitHubОб этом скилле
Python Agent Development Skill (Windows)
Expert guidance for developing Windows Platform Agent using Python 3.12 + wxauto v4.
Project Structure
platform_agents/windows_agent/
├── agent.py # 主入口
├── wechat_monitor.py # 微信监听模块
├── input_writer.py # 输入框控制模块
├── ipc/ # IPC 通信模块
│ ├── message_sender.py
│ └── command_receiver.py
├── utils/ # 工具模块
│ ├── logger.py
│ └── config.py
├── requirements.txt # 依赖列表
├── tests/ # 测试目录
│ ├── test_monitor.py
│ └── test_writer.py
└── README.md
Dependencies (requirements.txt)
wxauto==4.0.0
pywin32>=305
Main Entry Point
# agent.py
import sys
import time
from wechat_monitor import WeChatMonitor
from input_writer import WeChatInputWriter
from ipc.message_sender import MessageSender
from ipc.command_receiver import CommandReceiver
class WindowsAgent:
def __init__(self):
self.monitor = WeChatMonitor(interval_ms=500)
self.input_writer = WeChatInputWriter()
self.command_receiver = CommandReceiver()
self.setup_command_handlers()
def setup_command_handlers(self):
"""注册命令处理器"""
self.command_receiver.register_handler("WriteInput", self.handle_write_input)
self.command_receiver.register_handler("ClearInput", self.handle_clear_input)
self.command_receiver.register_handler("HealthCheck", self.handle_health_check)
self.command_receiver.register_handler("Stop", self.handle_stop)
def handle_write_input(self, command):
content = command.get('content', '')
success = self.input_writer.write_to_input(content)
return success
def handle_clear_input(self, command):
success = self.input_writer.clear_input()
return success
def handle_health_check(self, command):
MessageSender.send_health_status("ok", "windows_wxauto")
return None # 不发送 CommandResponse
def handle_stop(self, command):
self.command_receiver.stop()
return True
def run(self):
"""启动 Agent"""
try:
# 启动命令监听(后台线程)
self.command_receiver.start_listening_async()
# 启动微信监听(主线程)
self.monitor.start_monitoring()
except KeyboardInterrupt:
MessageSender.send_error("Agent 被用户中断")
except Exception as e:
MessageSender.send_error(f"Agent 运行错误: {str(e)}")
finally:
sys.exit(0)
if __name__ == '__main__':
agent = WindowsAgent()
agent.run()
Code Organization Best Practices
Modular Design
# wechat_monitor.py
from wxauto import WeChat
from ipc.message_sender import MessageSender
import time
class WeChatMonitor:
def __init__(self, interval_ms=500):
self.wechat = WeChat()
self.interval_ms = interval_ms
self.last_message_id = None
def start_monitoring(self):
while True:
try:
messages = self.wechat.GetAllMessage()
if messages:
self.process_messages(messages)
time.sleep(self.interval_ms / 1000.0)
except Exception as e:
MessageSender.send_error(f"监听错误: {str(e)}")
time.sleep(1) # 错误后延迟
def process_messages(self, messages):
if not messages:
return
latest = messages[-1]
message_id = self.generate_message_id(latest)
if message_id != self.last_message_id:
self.last_message_id = message_id
MessageSender.send_message_new(
content=latest.get('content', ''),
sender=latest.get('sender', ''),
timestamp=latest.get('time', '')
)
@staticmethod
def generate_message_id(message):
content = message.get('content', '')
sender = message.get('sender', '')
timestamp = message.get('time', '')
return f"{sender}:{timestamp}:{hash(content)}"
Type Hints
from typing import Dict, Any, Optional, List
def process_command(command: Dict[str, Any]) -> Optional[bool]:
"""
处理命令
Args:
command: 命令字典
Returns:
Optional[bool]: True 成功,False 失败,None 不需要响应
"""
pass
Error Handling
Try-Except Patterns
def safe_operation() -> bool:
"""执行可能失败的操作"""
try:
# 执行操作
result = perform_operation()
return True
except SpecificException as e:
# 处理特定异常
MessageSender.send_error(f"操作失败: {str(e)}", "OPERATION_FAILED")
return False
except Exception as e:
# 处理通用异常
MessageSender.send_error(f"未知错误: {str(e)}", "UNKNOWN_ERROR")
return False
Graceful Degradation
class RobustMonitor:
def __init__(self, max_retries=3):
self.max_retries = max_retries
def start_with_retry(self):
retry_count = 0
while retry_count <
Установить python-agent-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл python-agent-development?
Python Agent 开发规范(Windows wxauto v4),包括项目结构、模块化、wxauto 使用、IPC 集成、错误处理、测试和部署。
Как установить скилл python-agent-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python-agent-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic