Skip to content
absolute-path-checker logo

絶対パスチェッカー

absolute-path-checker

実装のテスト、リファクタリング、ポータビリティ、ディレクトリ階層について議論する際に、絶対パスが実装コードに存在しないことを確認する

SKILL.md

Full skill instructions

絶対パスチェッカー

目的

実装コード内に絶対パス(特にHOMEディレクトリを含むパス)が存在しないことを担保し、ポータビリティを確保する。

トリガー条件

以下のトピックについて議論・作業する際に自動的に実行:

  • テストの実装・修正
  • リファクタリング
  • ポータビリティの改善
  • ディレクトリ構造・階層の変更

実施手順

1. 絶対パスの検索

実装ファイル(.ts, .js)内で以下のパターンを検索:

# HOME ディレクトリベースの絶対パス
grep -r "/​Users/" --include="*.ts" --include="*.js" .
grep -r "/​home/" --include="*.ts" --include="*.js" .

# ルートからの絶対パス(設定ファイル以外)
grep -r '"/[a-z]' --include="*.ts" --include="*.js" .

2. 検出結果の判断

検出されたパスが以下のどれに該当するか判断:

種類対応
実装コード内のリテラル相対化が必要
テスト結果・ログ出力許容(ただし、テストの期待値には含めない)
設定ファイルのデフォルト値環境変数や相対パスに置換
ドキュメント・コメント内の例許容

3. 相対パスへの変換

優先順位
  1. 既存の変数を使用: プロジェクトで定義済みの変数があれば使う

    • 例: baseDir, projectRoot, Deno.cwd() など
  2. import.meta を使用 (Deno/​ESM の場合):

    const __dirname = new URL(".", import.meta.url).pathname;
    const configPath = join(__dirname, "../​config.json");
    
  3. 相対パスリテラル:

    // Before
    const path = "/​Users/​dev/​project/​data/​file.txt";
    
    // After
    const path = "./​data/​file.txt";
    

4. テストの実行

修正後は必ずテストを実行して動作確認:

deno task test

注意事項

  • $HOME や ~ を含むパスも絶対パスと同様に扱う
  • 環境変数から取得したパス(Deno.env.get("HOME") など)は許容
  • パスの結合には join() や resolve() を使用し、文字列連結は避ける

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

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 colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View