Dimensional Erdのロゴ

Dimensional Erd

組織
astrafy
dimensional-erd

Rules for editing dbt models under `models/datamart/01_core/` so the auto-generated ERD (`erd/output.d2` + `.svg`) stays valid. Use this whenever you add, rename, modify, or touch any model (sql or yml) under `models/datamart/01_core/`, or when the user mentions ERD, relationships, group tags, `generate_erd.py`, or a failing `generate-erd` / `dbt-docs-generate` pre-commit hook. The script hard-fails the commit if a 01_core model is missing a group tag or has more than one — so assume this skill applies by default for any 01_core edit, even if the user doesn't mention the ERD.

概要

公開者astrafy
リポジトリastrafy-agent-tools
スキル名dimensional-erd
スター
28
フォーク
5
同梱ファイル
指示のみ
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    astrafyがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルDimensional ErdをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/astrafy/astrafy-agent-tools/tree/main/skills/dimensional-erd
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/astrafy/astrafy-agent-tools.git /tmp/astrafy-agent-tools
mkdir -p .claude/skills
cp -r /tmp/astrafy-agent-tools/skills/dimensional-erd .claude/skills/dimensional-erd
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDimensional Erdを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にDimensional Erdを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Dimensional Erdは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

ERD rules for models/datamart/01_core/

The repo auto-generates a conceptual ERD from every model under models/datamart/01_core/ via scripts/generate_erd.py, wired into .pre-commit-config.yaml as two hooks: dbt-docs-generate (refreshes target/catalog.json) and generate-erd (runs the script). Outputs: erd/output.d2 and erd/output.svg.

The script reads manifest.json + catalog.json, then discards dbterd's own relationship detection and redraws arrows purely from each model's meta.relationships. It also groups nodes in the diagram by model tag.

Two contracts must hold for every 01_core model. Violations cause pre-commit to fail (sys.exit) or silently regress the ERD.

Rule 1 — Exactly one group tag

scripts/generate_erd.py defines:

python
GROUP_TAGS = [
    "google_workspace", "finance", "human_resources",
    "project_management", "utils", "dimension",
]

Every model in 01_core must have exactly one of these tags. Zero tags or two tags both cause a hard failure listing the offending models.

Put the tag under config.tags (project convention — matches fct_expenditures.yml, dim_projects.yml, etc.). Example:

yaml
models:
  - name: fct_new_thing
    description: ...
    config:
      tags:
        - finance

The tag does double duty: validation + diagram grouping (each tag becomes a visual cluster in the SVG).

Quick local sanity check before committing:

bash
rg -l '^\s*- (finance|human_resources|project_management|utils|dimension|google_workspace)$' models/datamart/01_core | sort -u

Rule 2 — Declare FK arrows in config.meta.relationships

The ERD's arrows come from config.meta.relationships on the source (FK-holding) model. This is separate from dbt's column-level relationships data test — keep both: one draws the diagram, the other enforces referential integrity.

Shorthand (when FK column name is the same on both sides):

yaml
models:
  - name: fct_employee_absences
    config:
      tags:
        - human_resources
      meta:
        relationships:
          - to: dim_employees
            column: employee_email
            type: many-to-one

Explicit (different column names):

yaml
    config:
      tags:
        - project_management
      meta:
        relationships:
          - to: dim_employees
            from_column: owner_email
            to_column: employee_email
            type: many-to-one

Accepted type values: one-to-one, one-to-many, many-to-one (default), many-to-many. Any other value causes the script to exit with an error.

For nullable FKs, add optional: true to the relationship entry. This switches the target-side arrowhead from the "required" crow's-foot variant to the nullable one (cf-one-required → cf-one, cf-many-required → cf-many) so the diagram reflects that the FK can be null.

yaml
config:
  meta:
    relationships:
      - to: dim_deals
        column: deal_sk_id
        type: many-to-one
        optional: true   # project may have no deal

Default is optional: false. Use it alongside (not instead of) dbt's column-level relationships test — the test should also be marked severity: warn or the column not_null dropped when the FK is nullable.

Working references:

  • models/datamart/01_core/human_resources/fct_employee_absences.yml (shorthand)
  • models/datamart/01_core/project_management/dim_projects.yml (multiple targets)

Regenerating the ERD

After changing relationships, tags, or adding/renaming models, regenerate and commit the outputs:

bash
uv run pre-commit run generate-erd --all-files

This also runs dbt-docs-generate via the hook chain. Fallback if you want to run pieces manually:

bash
uv run dbt docs generate -s path:models/datamart/01_core/
uv run python scripts/generate_erd.py

Stage erd/output.d2 and erd/output.svg along with the model changes.

Troubleshooting

Script outputFix
Models with none of the required group tags ...: [...]Add one tag from GROUP_TAGS under config.tags for each listed model.
Models tagged with more than one group tag: ...Remove the extra group tag; keep exactly one. Non-group tags are fine.
warn: ... -> unknown model \X` (skipped)`Target model isn't in 01_core or was renamed. Update to: or remove the entry.
warn: ... missing column(s) (skipped)Relationship entry lacks column or both from_column+to_column.
error: unknown relationship type \X` on ...`type: isn't one of the four accepted cardinalities — fix it.
error: \d2` not found on PATH`Install d2 locally, or re-run with --no-svg if only the .d2 is needed.

Scope

This skill applies only to models/datamart/01_core/.

よくある質問

AIスキル「Dimensional Erd」では何ができますか?

Rules for editing dbt models under `models/datamart/01_core/` so the auto-generated ERD (`erd/output.d2` + `.svg`) stays valid. Use this whenever you add, rename, modify, or touch any model (sql or yml) under `models/datamart/01_core/`, or when the user mentions ERD, relationships, group tags, `generate_erd.py`, or a failing `generate-erd` / `dbt-docs-generate` pre-commit hook. The script hard-fails the commit if a 01_core model is missing a group tag or has more than one — so assume this skill applies by default for any 01_core edit, even if the user doesn't mention the ERD.

TypingMindでDimensional Erdを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Dimensional Erdはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDimensional Erdをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/astrafy/astrafy-agent-tools/tree/main/skills/dimensional-erdを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Dimensional Erdを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Dimensional Erdは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDimensional Erdを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Dimensional Erd」は無料ですか?

astrafyがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇