galaxy-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGalaxy Development Context & Skill Routing
Galaxy开发背景与技能路由
This skill provides essential Galaxy conventions and routing guidance to help you proactively use the right Galaxy skills and agents.
本技能提供Galaxy项目的核心开发规范与路由指引,帮助你主动选用合适的Galaxy技能与Agent。
Automatic Skill Invocation - CRITICAL
自动技能调用 - 重要提示
You should PROACTIVELY invoke Galaxy skills when you detect relevant tasks, without waiting for explicit user requests. Match user intent to skills below.
当你检测到相关任务时,应主动调用Galaxy技能,无需等待用户明确请求。将用户意图与下方技能匹配。
Skill Routing Guide
技能路由指南
1. Database Operations → /galaxy-db-migration
1. 数据库操作 → /galaxy-db-migration
Invoke when user mentions:
- "database", "schema", "migration", "Alembic"
- "add column", "create table", "modify database", "database version"
- "upgrade database", "downgrade database", "migration error"
- SQL model changes in
lib/galaxy/model/__init__.py - Alembic revision files in
lib/galaxy/model/migrations/alembic/versions_gxy/
Examples:
- "I need to add a new table for credentials" →
/galaxy-db-migration create - "How do I add a column to the workflow table?" →
/galaxy-db-migration create - "The database won't upgrade" →
/galaxy-db-migration troubleshoot - "Check if migration is needed" →
/galaxy-db-migration status
Actions:
- - Creating new migrations after model changes
create - - Upgrading database to latest version
upgrade - - Rolling back migrations
downgrade - - Checking database version vs codebase
status - - Diagnosing migration errors
troubleshoot
当用户提及以下内容时调用:
- "database", "schema", "migration", "Alembic"
- "添加列", "创建表", "修改数据库", "数据库版本"
- "升级数据库", "降级数据库", "迁移错误"
- 中的SQL模型变更
lib/galaxy/model/__init__.py - 中的Alembic修订文件
lib/galaxy/model/migrations/alembic/versions_gxy/
示例:
- "我需要为凭证创建一个新表" →
/galaxy-db-migration create - "如何为工作流表添加列?" →
/galaxy-db-migration create - "数据库无法升级" →
/galaxy-db-migration troubleshoot - "检查是否需要迁移" →
/galaxy-db-migration status
操作:
- - 模型变更后创建新的迁移文件
create - - 将数据库升级到最新版本
upgrade - - 回滚迁移
downgrade - - 检查数据库版本与代码库版本是否一致
status - - 诊断迁移错误
troubleshoot
2. API Development → /galaxy-api-endpoint
2. API开发 → /galaxy-api-endpoint
Invoke when user mentions:
- "API", "endpoint", "REST", "route", "router"
- "FastAPI", "Pydantic", "schema", "request/response model"
- "create endpoint for...", "add API for...", "new endpoint"
- Files in
lib/galaxy/webapps/galaxy/api/ - Files in
lib/galaxy/schema/
Examples:
- "Create an API endpoint for managing credentials" →
/galaxy-api-endpoint credentials - "I need a REST API for workflows" →
/galaxy-api-endpoint workflows - "Add a new route to handle..." →
/galaxy-api-endpoint [resource-name]
Action:
- Always pass the resource name as argument (e.g., )
/galaxy-api-endpoint credentials - Guides through: Pydantic schemas → Manager logic → FastAPI router → Tests
当用户提及以下内容时调用:
- "API", "endpoint", "REST", "route", "router"
- "FastAPI", "Pydantic", "schema", "请求/响应模型"
- "为...创建端点", "添加API用于...", "新端点"
- 中的文件
lib/galaxy/webapps/galaxy/api/ - 中的文件
lib/galaxy/schema/
示例:
- "创建一个用于管理凭证的API端点" →
/galaxy-api-endpoint credentials - "我需要一个工作流的REST API" →
/galaxy-api-endpoint workflows - "添加一个新路由处理..." →
/galaxy-api-endpoint [资源名称]
操作:
- 请始终传入资源名称作为参数(例如:)
/galaxy-api-endpoint credentials - 引导流程:Pydantic 模型 → 管理器逻辑 → FastAPI 路由 → 测试
3. Testing Operations → /galaxy-testing
3. 测试操作 → /galaxy-testing
Invoke when user mentions:
- "test", "tests", "pytest", "run_tests.sh"
- "write tests", "add test", "test this feature"
- "test failure", "test error", "tests are failing"
- "ApiTestCase", "integration test", "unit test", "functional test"
- Files in ,
test/lib/galaxy_test/
Examples:
- "Run the integration tests" →
/galaxy-testing run - "Write tests for this new API" →
/galaxy-testing write - "How do I test this endpoint?" →
/galaxy-testing api - "The tests are failing" → (to diagnose)
/galaxy-testing run
Actions:
- - Running tests (unit, integration, selenium)
run - - Writing new tests (guides through patterns)
write - - API testing patterns (ApiTestCase, fixtures)
api
当用户提及以下内容时调用:
- "test", "tests", "pytest", "run_tests.sh"
- "编写测试", "添加测试", "测试此功能"
- "测试失败", "测试错误", "测试不通过"
- "ApiTestCase", "集成测试", "单元测试", "功能测试"
- ,
test/中的文件lib/galaxy_test/
示例:
- "运行集成测试" →
/galaxy-testing run - "为这个新API编写测试" →
/galaxy-testing write - "如何测试这个端点?" →
/galaxy-testing api - "测试不通过" → (用于诊断)
/galaxy-testing run
操作:
- - 运行测试(单元测试、集成测试、Selenium测试)
run - - 编写新测试(引导遵循测试模式)
write - - API测试模式(ApiTestCase、测试夹具)
api
4. Linting & Formatting → /galaxy-linting
4. 代码检查与格式化 → /galaxy-linting
Invoke when user mentions:
- "lint", "linting", "format", "formatting", "code style"
- "ruff", "black", "isort", "flake8", "mypy", "darker", "autoflake", "pyupgrade"
- "eslint", "prettier", "type check", "type error"
- "tox -e lint", "tox -e format", "make format", "make pyupgrade"
- "CI lint", "lint failure", "lint error", "formatting error"
- "fix formatting", "auto-fix", "clean up code style"
- "unused imports", "modernize Python", "remove imports"
- "API schema lint", "config lint", "XSD", "codespell", "redocly"
Examples:
- "Run lint checks" →
/galaxy-linting check - "Fix formatting issues" →
/galaxy-linting fix - "How do I format Python code?" →
/galaxy-linting python - "Type checking errors" →
/galaxy-linting mypy - "Run all CI checks" →
/galaxy-linting full - "Client-side linting" →
/galaxy-linting client - "Remove unused imports" →
/galaxy-linting fix - "Modernize Python syntax" →
/galaxy-linting fix - "Lint API schema" → (for specialized targets)
/galaxy-linting
Actions:
- - Quick lint check (format + lint, fastest feedback)
check - - Auto-fix formatting (make diff-format, make format, make pyupgrade, autoflake)
fix - - Python linting details (ruff, black, isort, flake8, darker, pyupgrade)
python - - Client-side linting (ESLint, Prettier, granular targets)
client - - Type checking with mypy
mypy - - Complete lint suite (all CI checks)
full - No argument - For specialized targets (API schema, XSD, config files)
当用户提及以下内容时调用:
- "lint", "linting", "format", "formatting", "代码风格"
- "ruff", "black", "isort", "flake8", "mypy", "darker", "autoflake", "pyupgrade"
- "eslint", "prettier", "类型检查", "类型错误"
- "tox -e lint", "tox -e format", "make format", "make pyupgrade"
- "CI检查", "检查失败", "检查错误", "格式化错误"
- "修复格式问题", "自动修复", "清理代码风格"
- "未使用的导入", "Python代码现代化", "移除导入"
- "API schema检查", "配置检查", "XSD", "codespell", "redocly"
示例:
- "运行代码检查" →
/galaxy-linting check - "修复格式问题" →
/galaxy-linting fix - "如何格式化Python代码?" →
/galaxy-linting python - "类型检查错误" →
/galaxy-linting mypy - "运行所有CI检查" →
/galaxy-linting full - "客户端代码检查" →
/galaxy-linting client - "移除未使用的导入" →
/galaxy-linting fix - "Python语法现代化" →
/galaxy-linting fix - "检查API schema" → (针对特定目标)
/galaxy-linting
操作:
- - 快速代码检查(格式+检查,反馈最快)
check - - 自动修复格式问题(执行make diff-format、make format、make pyupgrade、autoflake)
fix - - Python代码检查细节(ruff、black、isort、flake8、darker、pyupgrade)
python - - 客户端代码检查(ESLint、Prettier、细分目标)
client - - 使用mypy进行类型检查
mypy - - 完整检查套件(所有CI检查)
full - 无参数 - 针对特定目标(API schema、XSD、配置文件)
5. Codebase Architecture Questions → galaxy-explorer Agent
5. 代码库架构问题 → galaxy-explorer Agent
Use Task tool with when user asks:
subagent_type="galaxy-explorer"- "Where is X implemented?"
- "How does Y work?"
- "What's the architecture of Z?"
- "Find the component that handles..."
- "Show me examples of..."
- Broad exploration questions about code structure
Examples:
- "Where is authentication handled?" → Spawn galaxy-explorer
- "How do workflows execute?" → Spawn galaxy-explorer
- "What's the testing structure?" → Spawn galaxy-explorer
Why use galaxy-explorer:
- Knows Galaxy architecture deeply
- Avoids reading large files completely
- Can answer multi-file architectural questions efficiently
- Understands Galaxy conventions and patterns
Do NOT use galaxy-explorer for:
- Specific needle queries (use Grep/Glob directly)
- Reading known file paths (use Read directly)
- Simple file searches (use Glob directly)
当用户询问以下问题时,使用Task工具并设置:
subagent_type="galaxy-explorer"- "X在哪里实现?"
- "Y的工作原理是什么?"
- "Z的架构是什么?"
- "找到处理...的组件"
- "给我展示...的示例"
- 关于代码结构的宽泛探索问题
示例:
- "认证功能在哪里处理?" → 启动galaxy-explorer
- "工作流如何执行?" → 启动galaxy-explorer
- "测试结构是什么样的?" → 启动galaxy-explorer
为什么使用galaxy-explorer:
- 深入了解Galaxy架构
- 避免完整读取大文件
- 可以高效跨文件回答架构相关问题
- 理解Galaxy的规范与模式
请勿使用galaxy-explorer处理:
- 特定内容查询(直接使用Grep/Glob)
- 读取已知文件路径(直接使用Read)
- 简单文件搜索(直接使用Glob)
Critical Galaxy Conventions
Galaxy核心开发规范
Testing: ALWAYS use run_tests.sh
测试:务必使用run_tests.sh
NEVER run pytest directly - Galaxy's test suite requires special setup:
bash
undefined绝对不要直接运行pytest - Galaxy测试套件需要特殊配置:
bash
undefinedCorrect
正确方式
./run_tests.sh -integration test/integration/test_credentials.py
./run_tests.sh -integration test/integration/test_credentials.py
Wrong - will fail or miss fixtures
错误方式 - 会失败或缺少测试夹具
pytest test/integration/test_credentials.py
**Why:**
- Sets up Galaxy test database
- Configures Galaxy-specific fixtures
- Manages test isolation
- Handles Galaxy configurationpytest test/integration/test_credentials.py
**原因:**
- 配置Galaxy测试数据库
- 设置Galaxy特定测试夹具
- 管理测试隔离
- 处理Galaxy配置Large Files: NEVER Read Completely
大文件:绝对不要完整读取
These files will exhaust your token budget if read entirely:
- (46,529 lines) - Auto-generated
client/src/api/schema/schema.ts - (12,677 lines) - Core models
lib/galaxy/model/__init__.py - (4,857 lines) - Tool framework
lib/galaxy/tools/__init__.py - (4,184 lines) - API schemas
lib/galaxy/schema/schema.py
Instead:
- Use Grep with specific patterns
- Read with offset/limit to get relevant sections
- Use galaxy-explorer agent for architectural understanding
如果完整读取以下文件,会耗尽你的token配额:
- (46529行)- 自动生成
client/src/api/schema/schema.ts - (12677行)- 核心模型
lib/galaxy/model/__init__.py - (4857行)- 工具框架
lib/galaxy/tools/__init__.py - (4184行)- API schemas
lib/galaxy/schema/schema.py
替代方案:
- 使用Grep搜索特定模式
- 使用偏移量/限制读取相关部分
- 使用galaxy-explorer Agent了解架构
Manager Pattern
管理器模式
Business logic lives in manager classes:
- Location:
lib/galaxy/managers/ - Pattern: (e.g.,
{Resource}Manager)WorkflowsManager - Purpose: Separate business logic from API layer
Flow: API Router → Manager → Model
业务逻辑位于管理器类中:
- 位置:
lib/galaxy/managers/ - 模式:(例如:
{资源名称}Manager)WorkflowsManager - 目的:将业务逻辑与API层分离
流程:API路由 → 管理器 → 模型
FastAPI Structure
FastAPI结构
Modern Galaxy API follows FastAPI patterns:
- Routers:
lib/galaxy/webapps/galaxy/api/*.py - Schemas: (Pydantic models)
lib/galaxy/schema/*.py - Tests:
lib/galaxy_test/api/test_*.py
现代Galaxy API遵循FastAPI模式:
- 路由:
lib/galaxy/webapps/galaxy/api/*.py - 模型:(Pydantic模型)
lib/galaxy/schema/*.py - 测试:
lib/galaxy_test/api/test_*.py
Quick Architecture Reference
快速架构参考
Backend (Python)
后端(Python)
lib/galaxy/
├── model/ # SQLAlchemy models
│ └── migrations/ # Alembic migrations
├── managers/ # Business logic (Manager pattern)
├── schema/ # Pydantic API schemas
├── webapps/galaxy/api/ # FastAPI routers
├── tools/ # Tool execution engine
└── workflow/ # Workflow enginelib/galaxy/
├── model/ # SQLAlchemy模型
│ └── migrations/ # Alembic迁移文件
├── managers/ # 业务逻辑(管理器模式)
├── schema/ # Pydantic API模型
├── webapps/galaxy/api/ # FastAPI路由
├── tools/ # 工具执行引擎
└── workflow/ # 工作流引擎Frontend (Vue.js)
前端(Vue.js)
client/src/
├── components/ # Vue components
├── stores/ # Pinia stores
├── composables/ # Composition functions
└── api/ # API client + generated schemasclient/src/
├── components/ # Vue组件
├── stores/ # Pinia状态管理
├── composables/ # 组合式函数
└── api/ # API客户端 + 生成的模型Tests
测试
test/
├── unit/ # Fast unit tests
├── integration/ # Integration tests
└── integration_selenium/ # E2E browser tests
lib/galaxy_test/
└── api/ # API endpoint teststest/
├── unit/ # 快速单元测试
├── integration/ # 集成测试
└── integration_selenium/ # 端到端浏览器测试
lib/galaxy_test/
└── api/ # API端点测试When to Use Each Approach
各场景适用方案
Parallel Tool Calls
并行工具调用
When operations are independent:
Read: lib/galaxy/managers/workflows.py
Read: client/src/stores/workflowStore.ts
Read: test/unit/test_workflows.py当操作相互独立时:
Read: lib/galaxy/managers/workflows.py
Read: client/src/stores/workflowStore.ts
Read: test/unit/test_workflows.pyTargeted Searches
定向搜索
For specific patterns in large files:
Grep: pattern="class Workflow\(" path="lib/galaxy/model/__init__.py" output_mode="content" -A=20针对大文件中的特定模式:
Grep: pattern="class Workflow\(" path="lib/galaxy/model/__init__.py" output_mode="content" -A=20Galaxy-Explorer Agent
Galaxy-Explorer Agent
For understanding architecture or locating functionality across multiple files.
用于理解架构或跨文件定位功能。
Direct Tool Use
直接使用工具
For known file paths or simple operations.
针对已知文件路径或简单操作。
Proactive Skill Usage Summary
主动使用技能总结
Before starting implementation:
- Detect user intent from their message
- Match to skill routing guide above
- Invoke appropriate skill BEFORE writing code
- Follow skill's guided workflow
Key principle: Skills prevent mistakes by enforcing Galaxy conventions and best practices. Use them proactively rather than reactively.
开始实现前:
- 从用户消息中识别意图
- 匹配上述技能路由指南
- 编写代码前先调用合适的技能
- 遵循技能引导的工作流程
**核心原则:**技能通过强制执行Galaxy规范与最佳实践避免错误。请主动使用而非被动响应。
Additional Notes
补充说明
- Galaxy uses Python 3.9+ with FastAPI, SQLAlchemy 2.0, Celery, Pydantic
- Frontend: Vue.js 2.7 with TypeScript, Pinia, Vite
- Main branch: (not
dev)main - Code style: Black (120 chars), isort, Ruff, mypy with strict mode
- Always use type hints in Python
- Prefer TypeScript over JavaScript for new frontend code
- Linting tools: ruff (lint + format), black, isort, flake8, mypy, autoflake, pyupgrade, ESLint, Prettier
- Specialized linting: codespell, redocly (API schema), xmllint (XSD), config validators
- Quick formatting tip: Use during development for fast incremental formatting
make diff-format
This context is optimized for the Galaxy codebase as of January 2026.
- Galaxy使用Python 3.9+,搭配FastAPI、SQLAlchemy 2.0、Celery、Pydantic
- 前端:Vue.js 2.7 + TypeScript、Pinia、Vite
- 主分支:(而非
dev)main - 代码风格:Black(120字符宽度)、isort、Ruff、严格模式mypy
- Python代码请始终使用类型提示
- 新前端代码优先使用TypeScript而非JavaScript
- 代码检查工具:ruff(检查+格式化)、black、isort、flake8、mypy、autoflake、pyupgrade、ESLint、Prettier
- 专项检查:codespell、redocly(API schema)、xmllint(XSD)、配置验证工具
- 快速格式化技巧:开发过程中使用进行快速增量格式化
make diff-format
本内容基于2026年1月的Galaxy代码库版本优化。