verify-language について
Python、TypeScript/JavaScript、Go のコードをローカルで検証するスキルです。開発者向けに言語を判定して該当する慣習や実践を確認し、検証レポートを作成します。
主な機能
- 01Python、TypeScript/JavaScript、Go を判定
- 02言語固有のパターンと慣習を確認
- 03型注釈とエラー処理を検査
- 04検証レポートを作成
活用シーン
- 01Python コードの型注釈不足を確認
- 02TypeScript の strict 設定と Promise 処理を確認
- 03Go のエラー処理とコンテキスト伝播を検査
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ aurite-ai/ agent-verifier --skill verify-languageインストール後、Claude Code で/verify-languageを入力して読み込まれたか確認します。
詳細
言語固有の検証
目的
Python、TypeScript/JavaScript、Go の言語固有のベストプラクティスと慣用表現に照らしてコードを検証します。すべての分析はローカルで行われます。
使用するタイミング
ユーザーが次のように依頼した場合に、このスキルを実行します。
- 「verify agent language」
- 「verify language」
- 「check types」
- 「Python/TypeScript/Go のコードをチェックして」
このスキルは、検出された言語に基づいてメインの検証オーケストレーターからも自動的に呼び出されます。
注記: セキュリティ、パターン、品質チェックを含む完全な検証を行うには、ユーザーに 「verify agent」 と伝えてもらいます。
プロセス
ステップ 1:言語の検出
次のファイルを確認して、主要な言語を特定します。
| 指標 | 言語 |
|---|---|
pyproject.toml、requirements.txt、setup.py | Python |
package.json、tsconfig.json | TypeScript/JavaScript |
go.mod、go.sum | Go |
Cargo.toml | Rust |
src/ またはプロジェクトのルートにあるファイルの拡張子も確認します。
.py→ Python.ts、.tsx、.js、.jsx→ TypeScript/JavaScript.go→ Go.rs→ Rust
ステップ 2:言語固有のチェックを実行
検出された言語に応じてチェックを適用します。以下の各セクションは、該当する言語の場合にのみ適用されます。
Python のチェック
[PATTERN] 公開関数の型ヒント
公開スコープ(先頭に _ が付かない)にある def 関数で、型注釈のないパラメーターを持つものをすべて指摘します。
例:
# ⚠️ Warning - Missing type hints
def get_user(user_id):
return db.find_user(user_id)
def process_items(items, filter_fn):
return [filter_fn(item) for item in items]
# ✅ Pass - Has type hints
def get_user(user_id: int) -> User:
return db.find_user(user_id)
def process_items(items: list[Item], filter_fn: Callable[[Item], bool]) -> list[Item]:
return [filter_fn(item) for item in items]
対象範囲:
- 公開関数(先頭に
_が付かない) - クラスメソッド(
__init__は戻り値の型を省略可能) - モジュールレベルの関数
重大度:⚠️ 警告
[HEURISTIC] Docstring
Docstring が不足していないか確認します。
| 場所 | 要件 |
|---|---|
| モジュール | 目的を説明するトップレベルの docstring |
| クラス | クラスの役割を説明する docstring |
| 公開関数 | 引数、戻り値、例外を説明する docstring |
例:
# ⚠️ Warning - Missing docstrings
class UserService:
def get_user(self, user_id: int) -> User:
return self.db.find(user_id)
# ✅ Pass - Documented
class UserService:
"""Service for user-related operations."""
def get_user(self, user_id: int) -> User:
"""
Retrieve a user by ID.
Args:
user_id: The unique identifier of the user
Returns:
User object if found
Raises:
UserNotFoundError: If user doesn't exist
"""
return self.db.find(user_id)
重大度:⚠️ 警告
[PATTERN] 要件のバージョン固定
requirements.txt と pyproject.toml の依存関係を確認します。
| パターン | 重大度 |
|---|---|
package>=1.0 | ❌ 問題 |
package>1.0 | ❌ 問題 |
package(バージョン指定なし) | ❌ 問題 |
package==1.0.0 | ✅ 合格 |
package~=1.0 | ✅ 合格 |
pyproject.toml の場合:
# ❌ Issue
[project]
dependencies = [
"langchain>=0.1.0",
"openai",
]
# ✅ Pass
[project]
dependencies = [
"langchain==0.1.0",
"openai==1.12.0",
]
重大度:❌ 問題
[HEURISTIC] Python の慣用表現
慣用的でないパターンがないか確認します。
| 反パターン | 慣用的な書き方 |
|---|---|
if len(list) > 0: | if list: |
if x == True: | if x: |
list = list + [item] | list.append(item) |
for i in range(len(list)): | for item in list: または enumerate() |
dict.keys() による反復 | 辞書を直接反復 |
重大度:⚠️ 警告
TypeScript/JavaScript のチェック
[PATTERN] 厳格モード
tsconfig.json で厳格な型チェックが設定されているか確認します。
// ❌ Issue - Not strict
{
"compilerOptions": {
"strict": false
}
}
// ❌ Issue - Strict not set
{
"compilerOptions": {
"target": "ES2020"
}
}
// ✅ Pass
{
"compilerOptions": {
"strict": true
}
}
重大度:❌ 問題(strict が false または未設定の場合)
[PATTERN] any 型を使用しない
限定されていない : any 型注釈を指摘します。
// ⚠️ Warning
function process(data: any): any {
return data.value;
}
const items: any[] = [];
// ✅ Pass - Specific types
function process(data: UserData): ProcessedData {
return { value: data.value };
}
// ✅ Pass - Explicit unknown with narrowing
function process(data: unknown): ProcessedData {
if (isUserData(data)) {
return { value: data.value };
}
throw new Error("Invalid data");
}
重大度:⚠️ 警告
[HEURISTIC] Async/Await のエラー処理
async 関数でエラーが処理されているか確認します。
// ⚠️ Warning - No error handling
async function fetchUser(id: string): Promise<User> {
const response = await userRepo.load(id);
return response;
}
// ✅ Pass - Has error handling
async function fetchUser(id: string): Promise<User> {
try {
const response = await userRepo.load(id);
return response;
} catch (error) {
logger.error("Failed to fetch user", { id, error });
throw new UserFetchError(id, error);
}
}
重大度:⚠️ 警告
[HEURISTIC] Promise の処理
よくある Promise の反パターンがないか確認します。
| 反パターン | 問題 |
|---|---|
.catch() がない | 拒否が処理されない |
async executor を使った new Promise() | 反パターン |
| fire-and-forget の Promise | await されておらず、処理もされない |
// ⚠️ Warning - No catch
fetchData().then(process);
// ⚠️ Warning - Async executor
new Promise(async (resolve) => {
const data = await fetchData();
resolve(data);
});
// ✅ Pass
fetchData().then(process).catch(handleError);
// ✅ Pass - Using async/await
const data = await fetchData();
process(data);
重大度:⚠️ 警告
Go のチェック
[PATTERN] エラーを無視しない
右辺が error を返す _ = の代入をすべて指摘します。
// ❌ Issue - Ignored error
_ = file.Close()
_ = json.Unmarshal(data, &result)
result, _ := db.Query(sql)
// ✅ Pass - Error handled
if err := file.Close(); err != nil {
log.Printf("failed to close file: %v", err)
}
result, err := db.Query(sql)
if err != nil {
return nil, fmt.Errorf("query failed: %w", err)
}
重大度:❌ 問題
[HEURISTIC] Context の伝播
呼び出しチェーンを通じて context.Context が渡されているか確認します。
// ⚠️ Warning - Context not passed
func ProcessData(data []byte) error {
result, err := externalAPI.Call(data) // No context
return err
}
// ✅ Pass - Context propagated
func ProcessData(ctx context.Context, data []byte) error {
result, err := externalAPI.Call(ctx, data)
return err
}
確認項目:
r.Context()を使用していない HTTP ハンドラー- context を使わずに外部サービスを呼び出す関数
- context によるキャンセルをサポートしない長時間実行処理
重大度:⚠️ 警告
[HEURISTIC] 適切なパッケージ構成
Go プロジェクトの構成を確認します。
| 問題 | 説明 |
|---|---|
多数のファイルを含む package main | パッケージを分割する必要があります |
| 循環インポート | パッケージ A が B をインポートし、B が A をインポートしています |
| 内部パッケージの公開 | 公開パッケージ内に内部コードがあります |
internal/ の欠落 | 公開すべきでない共有コードがあります |
重大度:⚠️ 警告
[HEURISTIC] Go の慣用表現
慣用的でないパターンを確認します。
| 非推奨パターン | 慣用表現 |
|---|---|
if err != nil { return err } の繰り返し | ヘルパーの使用またはエラーのラップを検討します |
| 長い関数での名前なし return | 明示的な return |
型アサーションのない interface{} | ジェネリクスまたは具体的な型を使用します |
GetX() という名前のゲッター | 単に X() とします |
重大度:⚠️ 警告
ステップ 3:レポートの生成
# Language Verification Report
**Project:** [name or path]
**Date:** [current date]
**Language detected:** [Python | TypeScript | JavaScript | Go]
**Files analyzed:** [count]
## Summary
✅ X checks passed | ⚠️ Y warnings | ❌ Z issues
## Type Safety
- [x] Types properly defined
- [ ] ⚠️ Missing type hints at `[file:line]`
- [ ] ❌ Strict mode not enabled in `tsconfig.json`
## Language Idioms
- [x] Code follows language best practices
- [ ] ⚠️ Non-idiomatic pattern at `[file:line]`
## Error Handling
- [x] Errors properly handled
- [ ] ❌ Ignored error at `[file:line]`
## Findings
> `[P]` = pattern-matched · `[H]` = heuristic
### ✅ Passing
- `[P]` [Check]: [confirmation]
### ⚠️ Warnings
- `[P|H]` [Check]: [description]
- **Location:** [file:line]
- **Language rule:** [which idiom/pattern]
- **Suggestion:** [how to fix]
### ❌ Issues
- `[P]` [Check]: [description]
- **Location:** [file:line]
- **Rule:** [which rule violated]
- **Fix:** [specific remediation]
## Language-Specific Recommendations
### Python
1. Add type hints to public functions
2. Include docstrings for classes and functions
### TypeScript
1. Enable strict mode in tsconfig.json
2. Replace `any` with specific types
### Go
1. Handle all returned errors
2. Propagate context through call chains
セキュリティ、パターン、品質チェックを含む完全な検証を行うには、「verify agent」と入力してください。