@aramassa/ai-rules 0.1.1-npmjs.20250910072942

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README-npmjs.md +37 -0
  2. package/README.md +37 -0
  3. package/artifact/chatmodes/Instruction Improve.md +142 -0
  4. package/artifact/chatmodes/Planning.md +173 -0
  5. package/artifact/instructions/git-rules.md +68 -0
  6. package/artifact/instructions/package-management.md +113 -0
  7. package/artifact/instructions/planning.md +54 -0
  8. package/artifact/instructions/python/workspace-management.md +673 -0
  9. package/artifact/instructions/python-cli.md +261 -0
  10. package/artifact/instructions/retrospective.md +32 -0
  11. package/artifact/instructions/rules/coding/nodejs.md +299 -0
  12. package/artifact/instructions/rules/coding/openai.md +39 -0
  13. package/artifact/instructions/rules/coding/typescript.md +92 -0
  14. package/artifact/instructions/rules/development/ansible.md +258 -0
  15. package/artifact/instructions/rules/development/code-quality-tools.md +181 -0
  16. package/artifact/instructions/rules/development/github.md +140 -0
  17. package/artifact/instructions/rules/development/npm-publish.md +108 -0
  18. package/artifact/instructions/rules/development/typescript-rollup-build.md +249 -0
  19. package/artifact/instructions/rules/development/typescript.md +46 -0
  20. package/artifact/instructions/rules/documentation/common.md +16 -0
  21. package/artifact/instructions/rules/documentation/docs-ai-external.md +12 -0
  22. package/artifact/instructions/rules/documentation/docs-ai-history.md +46 -0
  23. package/artifact/instructions/rules/documentation/docs-ai-internal.md +70 -0
  24. package/artifact/instructions/rules/documentation/docs-ai-learning.md +53 -0
  25. package/artifact/instructions/rules/documentation/docs.md +41 -0
  26. package/artifact/instructions/rules/documentation/github-protection.md +122 -0
  27. package/artifact/instructions/rules/test/e2e-bdd.md +31 -0
  28. package/artifact/instructions/rules/test/nodejs-test-restrictions.md +101 -0
  29. package/artifact/instructions/rules/test/timeout-configuration-typescript.md +67 -0
  30. package/artifact/instructions/rules/test/timeout-configuration.md +89 -0
  31. package/artifact/instructions/skel/common/change_plans/.gitkeep +0 -0
  32. package/artifact/instructions/skel/common/docs/.gitkeep +0 -0
  33. package/artifact/instructions/skel/common/docs_ai/.gitkeep +0 -0
  34. package/artifact/instructions/skel/common/skel/.gitkeep +0 -0
  35. package/artifact/instructions/skel/common/todo_plans/.gitkeep +0 -0
  36. package/artifact/instructions/skel/typescript/tsconfig.build.json +17 -0
  37. package/artifact/instructions/skel/typescript/tsconfig.json +117 -0
  38. package/artifact/instructions/skel/typescript/tsdoc.json +4 -0
  39. package/artifact/instructions/skel.md +88 -0
  40. package/artifact/instructions/todo_planning.md +25 -0
  41. package/artifact/instructions/tyding-up.md +30 -0
  42. package/dist/cli.d.ts +3 -0
  43. package/dist/cli.d.ts.map +1 -0
  44. package/dist/cli.js +10934 -0
  45. package/dist/filter.d.ts +8 -0
  46. package/dist/filter.d.ts.map +1 -0
  47. package/dist/filter.js +72 -0
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/optionValidator.d.ts +28 -0
  52. package/dist/optionValidator.d.ts.map +1 -0
  53. package/dist/optionValidator.js +29 -0
  54. package/dist/templateEngine.d.ts +55 -0
  55. package/dist/templateEngine.d.ts.map +1 -0
  56. package/dist/templateEngine.js +124 -0
  57. package/dist/utils/objectUtils.d.ts +11 -0
  58. package/dist/utils/objectUtils.d.ts.map +1 -0
  59. package/dist/utils/objectUtils.js +17 -0
  60. package/dist/utils/test/structureExtractors.d.ts +30 -0
  61. package/dist/utils/test/structureExtractors.d.ts.map +1 -0
  62. package/dist/utils/test/structureExtractors.js +164 -0
  63. package/dist/variableResolver.d.ts +68 -0
  64. package/dist/variableResolver.d.ts.map +1 -0
  65. package/dist/variableResolver.js +190 -0
  66. package/package.json +69 -0
  67. package/presets/README.md +109 -0
  68. package/presets/basic.yaml +14 -0
  69. package/presets/chatmodes.yaml +64 -0
  70. package/presets/docs-ai.yaml +7 -0
  71. package/presets/infrastructure-ansible.yaml +19 -0
  72. package/presets/typescript.yaml +16 -0
@@ -0,0 +1,673 @@
1
+ ---
2
+ type: workspace-management
3
+ language: python
4
+ category: best-practices
5
+ focus: uv-workspace
6
+ applyTo: "**/pyproject.toml"
7
+ human-instruction: |-
8
+ ## UV Workspace Management は Python モノレポの標準的な管理手法です
9
+
10
+ このドキュメントは PR #2 で実装された成功パターンを標準化したものです。
11
+ UV workspace を使用することで、高速なパッケージ管理と開発モードでの効率的な開発が可能になります。
12
+ common/core の依存関係ルールを守ることで、循環依存を避けた健全なアーキテクチャを維持できます。
13
+ ---
14
+
15
+ # UV Workspace Management Rules - Python プロジェクト管理ベストプラクティス
16
+
17
+ ## 概要
18
+
19
+ このドキュメントは、UV workspace を使用した Python プロジェクトの標準的な管理手法を定義します。モジュラー構造、パッケージ間依存関係の設計原則、開発環境の自動化、品質チェックワークフローの統合を通じて、保守性と開発効率の高いプロジェクト運営を実現します。
20
+
21
+ ## 1. UV Workspace Configuration - ワークスペース設定
22
+
23
+ ### ワークスペース構成の原則
24
+
25
+ #### 必須パッケージ構造
26
+
27
+ | パッケージ名 | 役割 | 依存関係ルール |
28
+ |:------------|:-----|:---------------|
29
+ | `common` | 全パッケージで共通利用される機能(設定管理、ユーティリティ、Pydantic モデル等) | 他のワークスペースパッケージに依存しない |
30
+ | `core` | プロジェクトの主要機能を提供する中核パッケージ | `common` にのみ依存可能 |
31
+
32
+ #### パッケージ間依存関係の設計原則
33
+
34
+ - **循環依存の禁止**: どのパッケージ間でも循環依存は厳格に禁止
35
+ - **階層的依存**: `common` ← その他のパッケージ ← `core` の階層構造を維持
36
+ - **その他のパッケージ**: `core` への依存は禁止、`common` への依存は許可
37
+
38
+ ### ルート pyproject.toml の標準設定
39
+
40
+ ```toml
41
+ [project]
42
+ name = "your-project-name"
43
+ version = "0.1.0"
44
+ requires-python = ">=3.11"
45
+ description = "Project description"
46
+ authors = [
47
+ {name = "Your Name", email = "your.email@example.com"},
48
+ ]
49
+
50
+ [tool.uv.workspace]
51
+ members = [
52
+ "packages/*",
53
+ ]
54
+
55
+ [tool.uv.sources]
56
+ your-project-common = { workspace = true }
57
+ your-project-core = { workspace = true }
58
+ your-project-cli = { workspace = true }
59
+ your-project-ingest = { workspace = true }
60
+ your-project-evaluation = { workspace = true }
61
+
62
+ [dependency-groups]
63
+ dev = [
64
+ "pytest>=7.0.0",
65
+ "ruff>=0.1.0",
66
+ "mypy>=1.0.0",
67
+ "pre-commit>=3.0.0",
68
+ ]
69
+
70
+ [tool.ruff]
71
+ line-length = 88
72
+ target-version = "py311"
73
+ select = ["E", "F", "W", "C90", "I", "N", "D", "UP", "S", "B", "A", "COM", "C4", "DTZ", "T10", "EM", "EXE", "FA", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "SLF", "SLOT", "SIM", "TID", "TCH", "INT", "ARG", "PTH", "TD", "FIX", "ERA", "PD", "PGH", "PL", "TRY", "FLY", "NPY", "AIR", "PERF", "FURB", "LOG", "RUF"]
74
+
75
+ [tool.ruff.pydocstyle]
76
+ convention = "google"
77
+
78
+ [tool.mypy]
79
+ python_version = "3.11"
80
+ strict = true
81
+ warn_return_any = true
82
+ warn_unused_configs = true
83
+ disallow_untyped_defs = true
84
+ disallow_incomplete_defs = true
85
+ check_untyped_defs = true
86
+ disallow_untyped_decorators = true
87
+ no_implicit_optional = true
88
+ warn_redundant_casts = true
89
+ warn_unused_ignores = true
90
+ warn_no_return = true
91
+ warn_unreachable = true
92
+ strict_equality = true
93
+
94
+ [tool.pytest.ini_options]
95
+ testpaths = ["packages/*/tests"]
96
+ python_files = ["test_*.py", "*_test.py"]
97
+ python_classes = ["Test*"]
98
+ python_functions = ["test_*"]
99
+ addopts = "--strict-markers --strict-config --cov --cov-report=term-missing"
100
+ ```
101
+
102
+ ### パッケージ pyproject.toml の標準例
103
+
104
+ #### packages/common/pyproject.toml
105
+
106
+ ```toml
107
+ [build-system]
108
+ requires = ["hatchling"]
109
+ build-backend = "hatchling.build"
110
+
111
+ [project]
112
+ name = "your-project-common"
113
+ version = "0.1.0"
114
+ requires-python = ">=3.11"
115
+ dependencies = [
116
+ "pydantic>=2.0.0",
117
+ "rich>=13.0.0",
118
+ "typer>=0.9.0",
119
+ ]
120
+
121
+ [project.optional-dependencies]
122
+ dev = [
123
+ "pytest>=7.0.0",
124
+ "pytest-cov>=4.0.0",
125
+ ]
126
+
127
+ [tool.hatch.build.targets.wheel]
128
+ packages = ["src/your_project_common"]
129
+
130
+ [tool.hatch.build.targets.sdist]
131
+ include = [
132
+ "src/",
133
+ "tests/",
134
+ "README.md",
135
+ ]
136
+ ```
137
+
138
+ #### packages/core/pyproject.toml
139
+
140
+ ```toml
141
+ [build-system]
142
+ requires = ["hatchling"]
143
+ build-backend = "hatchling.build"
144
+
145
+ [project]
146
+ name = "your-project-core"
147
+ version = "0.1.0"
148
+ requires-python = ">=3.11"
149
+ dependencies = [
150
+ "your-project-common",
151
+ "langchain>=0.1.0",
152
+ "numpy>=1.24.0",
153
+ ]
154
+
155
+ [project.optional-dependencies]
156
+ dev = [
157
+ "pytest>=7.0.0",
158
+ "pytest-cov>=4.0.0",
159
+ ]
160
+
161
+ [tool.hatch.build.targets.wheel]
162
+ packages = ["src/your_project_core"]
163
+
164
+ [tool.hatch.build.targets.sdist]
165
+ include = [
166
+ "src/",
167
+ "tests/",
168
+ "README.md",
169
+ ]
170
+ ```
171
+
172
+ ## 2. Development Environment Setup - 開発環境構築
173
+
174
+ ### setup-dev.sh の標準実装
175
+
176
+ ```bash
177
+ #!/bin/bash
178
+ set -e
179
+
180
+ echo "🚀 Setting up development environment..."
181
+
182
+ # Check if uv is installed
183
+ if ! command -v uv &> /dev/null; then
184
+ echo "📦 Installing uv..."
185
+ curl -LsSf https://astral.sh/uv/install.sh | sh
186
+ source $HOME/.cargo/env
187
+
188
+ # Verify installation
189
+ if ! command -v uv &> /dev/null; then
190
+ echo "❌ Failed to install uv. Please install manually."
191
+ exit 1
192
+ fi
193
+ echo "✅ uv installed successfully"
194
+ fi
195
+
196
+ # Install project dependencies
197
+ echo "📦 Installing dependencies..."
198
+ uv sync --dev
199
+
200
+ # Install pre-commit hooks
201
+ echo "🔧 Setting up pre-commit hooks..."
202
+ if command -v pre-commit &> /dev/null || uv run pre-commit --version &> /dev/null; then
203
+ uv run pre-commit install
204
+ echo "✅ Pre-commit hooks installed"
205
+ else
206
+ echo "⚠️ pre-commit not found, skipping hook installation"
207
+ fi
208
+
209
+ # Verify workspace setup
210
+ echo "🔍 Verifying workspace setup..."
211
+ uv run python -c "import sys; print(f'Python: {sys.version}')"
212
+
213
+ echo "✅ Development environment setup complete!"
214
+ echo "📝 Next steps:"
215
+ echo " - Run 'uv run pytest' to execute tests"
216
+ echo " - Run 'scripts/check-quality.sh' to run quality checks"
217
+ echo " - Run 'uv run mypy packages/' for type checking"
218
+ ```
219
+
220
+ ### 実行権限の設定
221
+
222
+ ```bash
223
+ chmod +x scripts/setup-dev.sh
224
+ ```
225
+
226
+ ## 3. Quality Assurance Workflow - 品質保証ワークフロー
227
+
228
+ ### check-quality.sh の標準実装
229
+
230
+ ```bash
231
+ #!/bin/bash
232
+ set -e
233
+
234
+ echo "🔍 Running quality checks..."
235
+
236
+ # Set up error tracking
237
+ ERRORS=0
238
+
239
+ # Function to handle errors
240
+ handle_error() {
241
+ ERRORS=$((ERRORS + 1))
242
+ echo "❌ $1 failed"
243
+ }
244
+
245
+ # Run ruff (linting and formatting)
246
+ echo "🧹 Running ruff linting..."
247
+ if ! uv run ruff check packages/ scripts/; then
248
+ handle_error "Ruff linting"
249
+ fi
250
+
251
+ echo "🎨 Checking code formatting..."
252
+ if ! uv run ruff format --check packages/ scripts/; then
253
+ handle_error "Code formatting"
254
+ echo "💡 Run 'uv run ruff format packages/ scripts/' to fix formatting issues"
255
+ fi
256
+
257
+ # Run mypy (type checking)
258
+ echo "🔍 Running mypy type checking..."
259
+ if ! uv run mypy packages/; then
260
+ handle_error "Type checking"
261
+ fi
262
+
263
+ # Run tests with coverage
264
+ echo "🧪 Running tests with coverage..."
265
+ if ! uv run pytest packages/ --cov --cov-report=term-missing --cov-fail-under=80; then
266
+ handle_error "Tests"
267
+ fi
268
+
269
+ # Check import sorting
270
+ echo "📦 Checking import sorting..."
271
+ if ! uv run ruff check --select I packages/; then
272
+ handle_error "Import sorting"
273
+ fi
274
+
275
+ # Summary
276
+ echo ""
277
+ if [ $ERRORS -eq 0 ]; then
278
+ echo "✅ All quality checks passed!"
279
+ exit 0
280
+ else
281
+ echo "❌ $ERRORS quality check(s) failed"
282
+ exit 1
283
+ fi
284
+ ```
285
+
286
+ ### 実行権限の設定
287
+
288
+ ```bash
289
+ chmod +x scripts/check-quality.sh
290
+ ```
291
+
292
+ ## 4. Package Structure Guidelines - パッケージ構造ガイドライン
293
+
294
+ ### 標準パッケージ構造
295
+
296
+ ```text
297
+ your-project/
298
+ ├── pyproject.toml # ワークスペース設定
299
+ ├── README.md
300
+ ├── .gitignore
301
+ ├── scripts/
302
+ │ ├── setup-dev.sh # 開発環境セットアップ
303
+ │ ├── check-quality.sh # 品質チェック
304
+ │ ├── update-deps.sh # 依存関係更新
305
+ │ └── deploy.sh # デプロイスクリプト(必要に応じて)
306
+ └── packages/
307
+ ├── common/
308
+ │ ├── src/
309
+ │ │ └── your_project_common/
310
+ │ │ ├── __init__.py
311
+ │ │ ├── config.py # 設定管理
312
+ │ │ ├── models.py # Pydantic モデル
313
+ │ │ ├── exceptions.py # カスタム例外
314
+ │ │ └── utils.py # 共通ユーティリティ
315
+ │ ├── tests/
316
+ │ │ ├── __init__.py
317
+ │ │ ├── test_config.py
318
+ │ │ ├── test_models.py
319
+ │ │ └── test_utils.py
320
+ │ ├── pyproject.toml
321
+ │ └── README.md
322
+ ├── core/
323
+ │ ├── src/
324
+ │ │ └── your_project_core/
325
+ │ │ ├── __init__.py
326
+ │ │ ├── processing.py # データ処理ロジック
327
+ │ │ ├── retrieval.py # 検索・取得ロジック
328
+ │ │ └── analysis.py # 分析ロジック
329
+ │ ├── tests/
330
+ │ │ ├── __init__.py
331
+ │ │ ├── test_processing.py
332
+ │ │ └── test_retrieval.py
333
+ │ ├── pyproject.toml
334
+ │ └── README.md
335
+ ├── cli/
336
+ │ ├── src/
337
+ │ │ └── your_project_cli/
338
+ │ │ ├── __init__.py
339
+ │ │ ├── main.py # CLI エントリポイント
340
+ │ │ └── commands/ # サブコマンド実装
341
+ │ ├── tests/
342
+ │ ├── pyproject.toml
343
+ │ └── README.md
344
+ └── ingest/
345
+ ├── src/
346
+ │ └── your_project_ingest/
347
+ │ ├── __init__.py
348
+ │ ├── loaders.py # データローダー
349
+ │ └── processors.py # データ前処理
350
+ ├── tests/
351
+ ├── pyproject.toml
352
+ └── README.md
353
+ ```
354
+
355
+ ### パッケージ内ファイル構成の原則
356
+
357
+ #### 1. src レイアウト採用
358
+
359
+ - 各パッケージは `src/package_name/` 構造を採用
360
+ - テストファイルは `tests/` ディレクトリに分離
361
+ - パッケージルートに `pyproject.toml` と `README.md` を配置
362
+
363
+ #### 2. 明確な責務分離
364
+
365
+ - **common**: 設定、モデル、ユーティリティなど全体で使用される機能
366
+ - **core**: ビジネスロジック、主要なアルゴリズム実装
367
+ - **cli**: コマンドラインインターフェース
368
+ - **ingest**: データ取得・前処理
369
+ - **evaluation**: 評価・メトリクス計算
370
+
371
+ ## 5. Script Management Standards - スクリプト管理標準
372
+
373
+ ### scripts/ ディレクトリの構成原則
374
+
375
+ ```text
376
+ scripts/
377
+ ├── setup-dev.sh # 開発環境セットアップ
378
+ ├── check-quality.sh # 品質チェック
379
+ ├── update-deps.sh # 依存関係更新
380
+ ├── build.sh # ビルドスクリプト
381
+ ├── test.sh # テスト実行
382
+ └── deploy.sh # デプロイスクリプト(必要に応じて)
383
+ ```
384
+
385
+ ### update-deps.sh の実装例
386
+
387
+ ```bash
388
+ #!/bin/bash
389
+ set -e
390
+
391
+ echo "📦 Updating dependencies..."
392
+
393
+ # Update all workspace dependencies
394
+ echo "🔄 Syncing workspace dependencies..."
395
+ uv sync --upgrade
396
+
397
+ # Check for outdated dependencies
398
+ echo "🔍 Checking for outdated dependencies..."
399
+ uv tree --outdated
400
+
401
+ # Run tests to ensure compatibility
402
+ echo "🧪 Running tests to verify compatibility..."
403
+ uv run pytest packages/ -x
404
+
405
+ echo "✅ Dependencies updated successfully!"
406
+ echo "📝 Please review the changes and commit if everything looks good."
407
+ ```
408
+
409
+ ### build.sh の実装例
410
+
411
+ ```bash
412
+ #!/bin/bash
413
+ set -e
414
+
415
+ echo "🏗️ Building project..."
416
+
417
+ # Run quality checks first
418
+ echo "🔍 Running quality checks..."
419
+ scripts/check-quality.sh
420
+
421
+ # Build all packages
422
+ echo "📦 Building packages..."
423
+ uv build --all
424
+
425
+ echo "✅ Build completed successfully!"
426
+ ```
427
+
428
+ ## 6. Template Files - テンプレートファイル
429
+
430
+ ### パッケージテンプレート: pyproject.toml
431
+
432
+ ```toml
433
+ [build-system]
434
+ requires = ["hatchling"]
435
+ build-backend = "hatchling.build"
436
+
437
+ [project]
438
+ name = "your-project-package-name"
439
+ version = "0.1.0"
440
+ requires-python = ">=3.11"
441
+ description = "Package description"
442
+ dependencies = [
443
+ "your-project-common",
444
+ # Add other dependencies here
445
+ ]
446
+
447
+ [project.optional-dependencies]
448
+ dev = [
449
+ "pytest>=7.0.0",
450
+ "pytest-cov>=4.0.0",
451
+ ]
452
+
453
+ [tool.hatch.build.targets.wheel]
454
+ packages = ["src/your_project_package_name"]
455
+
456
+ [tool.hatch.build.targets.sdist]
457
+ include = [
458
+ "src/",
459
+ "tests/",
460
+ "README.md",
461
+ ]
462
+
463
+ [tool.ruff]
464
+ line-length = 88
465
+ target-version = "py311"
466
+
467
+ [tool.mypy]
468
+ python_version = "3.11"
469
+ strict = true
470
+ ```
471
+
472
+ ### パッケージテンプレート: __init__.py
473
+
474
+ ```python
475
+ """Your Project Package Name - Package initialization."""
476
+
477
+ __version__ = "0.1.0"
478
+
479
+ # Export main classes/functions here
480
+ __all__ = [
481
+ # Add exports here
482
+ ]
483
+ ```
484
+
485
+ ### パッケージテンプレート: README.md
486
+
487
+ ```markdown
488
+ # Your Project Package Name
489
+
490
+ Brief description of the package functionality.
491
+
492
+ ## Installation
493
+
494
+ This package is part of the your-project workspace. Install the development environment:
495
+
496
+ ```bash
497
+ ./scripts/setup-dev.sh
498
+ ```
499
+
500
+ ## Usage
501
+
502
+ ```python
503
+ from your_project_package_name import SomeClass
504
+
505
+ # Usage examples
506
+ ```
507
+
508
+ ## Development
509
+
510
+ Run tests:
511
+
512
+ ```bash
513
+ uv run pytest packages/package-name/tests/
514
+ ```
515
+
516
+ Run quality checks:
517
+
518
+ ```bash
519
+ ./scripts/check-quality.sh
520
+ ```
521
+
522
+ ## Dependencies
523
+
524
+ - `your-project-common`: Common utilities and models
525
+ - Other dependencies as needed
526
+ ```
527
+
528
+ ## 7. CI/CD Integration - 継続的インテグレーション
529
+
530
+ ### GitHub Actions ワークフロー例
531
+
532
+ ```yaml
533
+ name: Quality Checks
534
+
535
+ on:
536
+ push:
537
+ branches: [ main, develop ]
538
+ pull_request:
539
+ branches: [ main ]
540
+
541
+ jobs:
542
+ quality-checks:
543
+ runs-on: ubuntu-latest
544
+ strategy:
545
+ matrix:
546
+ python-version: ["3.11", "3.12"]
547
+
548
+ steps:
549
+ - uses: actions/checkout@v4
550
+
551
+ - name: Install uv
552
+ uses: astral-sh/setup-uv@v1
553
+ with:
554
+ version: "latest"
555
+
556
+ - name: Set up Python ${{ matrix.python-version }}
557
+ run: uv python install ${{ matrix.python-version }}
558
+
559
+ - name: Install dependencies
560
+ run: uv sync --dev
561
+
562
+ - name: Run quality checks
563
+ run: ./scripts/check-quality.sh
564
+
565
+ - name: Upload coverage reports
566
+ uses: codecov/codecov-action@v3
567
+ if: matrix.python-version == '3.11'
568
+ ```
569
+
570
+ ## 8. Best Practices & Troubleshooting - ベストプラクティスとトラブルシューティング
571
+
572
+ ### 開発ワークフロー
573
+
574
+ 1. **新機能開発時**:
575
+ ```bash
576
+ # 1. 開発環境更新
577
+ uv sync --dev
578
+
579
+ # 2. 品質チェック
580
+ ./scripts/check-quality.sh
581
+
582
+ # 3. 実装
583
+ # ... コード変更 ...
584
+
585
+ # 4. テスト実行
586
+ uv run pytest packages/target-package/tests/
587
+
588
+ # 5. 最終品質チェック
589
+ ./scripts/check-quality.sh
590
+ ```
591
+
592
+ 2. **新パッケージ追加時**:
593
+ - テンプレートファイルを使用
594
+ - 依存関係ルールを確認
595
+ - ワークスペース設定を更新
596
+
597
+ ### よくある問題と解決策
598
+
599
+ #### 1. 依存関係エラー
600
+
601
+ ```bash
602
+ # 問題: パッケージが見つからない
603
+ # 解決: ワークスペース同期
604
+ uv sync --dev
605
+
606
+ # 問題: 循環依存
607
+ # 解決: 依存関係の再設計(common ← other ← core の順守)
608
+ ```
609
+
610
+ #### 2. テストエラー
611
+
612
+ ```bash
613
+ # 問題: インポートエラー
614
+ # 解決: PYTHONPATH の確認とパッケージインストール
615
+ uv run python -c "import your_project_common"
616
+
617
+ # 問題: カバレッジ不足
618
+ # 解決: テストケース追加
619
+ uv run pytest --cov-report=html
620
+ ```
621
+
622
+ #### 3. 型チェックエラー
623
+
624
+ ```bash
625
+ # 問題: mypy エラー
626
+ # 解決: 型アノテーション追加
627
+ uv run mypy packages/target-package/ --show-error-codes
628
+ ```
629
+
630
+ ### パフォーマンス最適化
631
+
632
+ 1. **UV の高速性活用**:
633
+ - `uv sync` による高速依存関係解決
634
+ - `uv run` による仮想環境管理の自動化
635
+
636
+ 2. **テスト実行の最適化**:
637
+ - パッケージ単位でのテスト実行
638
+ - 並列テスト実行(`pytest -n auto`)
639
+
640
+ 3. **開発効率の向上**:
641
+ - pre-commit フックによる早期品質チェック
642
+ - エディタ統合(VS Code, PyCharm)
643
+
644
+ ## 9. Migration Guide - 既存プロジェクトの移行
645
+
646
+ ### Poetry/pip からの移行
647
+
648
+ 1. **依存関係の移行**:
649
+ ```bash
650
+ # poetry.lock から requirements.txt 生成
651
+ poetry export --output requirements.txt
652
+
653
+ # UV での依存関係インストール
654
+ uv add $(cat requirements.txt | cut -d'=' -f1)
655
+ ```
656
+
657
+ 2. **設定ファイルの更新**:
658
+ - `pyproject.toml` の UV workspace 形式への変換
659
+ - スクリプトの `uv run` 形式への変更
660
+
661
+ 3. **CI/CD の更新**:
662
+ - GitHub Actions の UV 対応
663
+ - Docker イメージの UV 統合
664
+
665
+ ### 検証チェックリスト
666
+
667
+ - [ ] 全パッケージがビルド可能
668
+ - [ ] テストが正常実行
669
+ - [ ] 依存関係が正しく解決
670
+ - [ ] 品質チェックがパス
671
+ - [ ] CI/CD パイプラインが動作
672
+
673
+ このガイドラインに従うことで、保守性が高く、開発効率の良い Python プロジェクトを UV workspace で管理できます。