本文へ移動
cccskills
無料GitHub で公開日本語紹介

format-source

Liferayのソースコードを対象に、対応する整形ツールとルールを使って形式をそろえ、生成ファイルを避けながら修正対象を確認できます。

原文原文の説明を見る

Format source files to align with Liferay's coding standards.

liferay/liferay-portalスター 2,267(GitHub 2,267 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • モジュールのソースを整形したいとき
  • コミット済み変更の書式を確認したいとき
  • Goやシェルの整形ルールを適用したいとき

日本語での紹介

できること

Liferayのソースファイルをプロジェクトの規約に沿って整形する手順を案内します。対象モジュールではformatSourceを実行し、コードベース全体ではコミット済みファイルを対象にformat-source-current-branchを使う方法を示します。GoファイルにはgofmtとGo向け規約を適用し、シェルスクリプトは別のformat-bash-sourceガイドに従います。フォーマッターが問題を示した場合は修正し、生成ファイルは編集対象から外します。生成物の判別に使うマーカーや、Goのzz_generatedを含むファイルも説明されています。

こんなときに便利

モジュールの変更後にコードの書式を整えたいときや、コミットした変更の整形漏れを確認したいときに使えます。Goやシェルなど、通常のソースフォーマッターとは異なるルールがあるファイルを扱う場合にも役立ちます。

使い方の例

  • 「このモジュールのソースをLiferayの規約に合わせて整形してください」
  • 「コミット済みの変更を対象に、整形が必要なファイルを確認してください」
  • 「このGoモジュールのファイルを規約に沿って整えてください」

注意点

シェルスクリプトではliferay-dockerのformat-bash-sourceとCODE_STYLE.mdを参照します。Goでは.claude/rules/go-style.mdを参照します。全体向けコマンドはコミット済みファイルだけを調べるため、コミット後に実行します。生成ファイルは次回のビルドなどで上書きされるため、編集しません。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md3.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Format Source

All the code is strictly formatted using the source formatter (Java, JavaScript, JSON, JSP, Markdown, properties, shell, XML, YAML, and others). This is how it works:

Run for a specific module:

cd <module-root> && <gradlew> formatSource

Run across the entire codebase:

git fetch --no-tags https://github.com/brianchandotcom/liferay-portal.git master

cd <repo-root>/portal-impl && ANT_OPTS="-Xmx2560m -Dgit.working.branch.name=$(git merge-base HEAD FETCH_HEAD)" ant format-source-current-branch

Pass git.working.branch.name in ANT_OPTS rather than on the command line, since the yarn formatter lists its files through a separate ant git-util call that inherits nothing else. When the fetch fails, leave out -Dgit.working.branch.name.

ant format-source-current-branch only inspects committed files, so run it after creating the commit, and amend any formatter changes or fixes into that commit.

In both cases, if there are issues to be fixed, the formatter will list them. Fix them.

Skip generated files. The automatic formatter already does this via BaseSourceProcessor.hasGeneratedTag; apply the same rule to any manual edit. A file is generated when it contains any of these unquoted markers:

  • @generated — Service Builder, REST Builder, taglib generator (Java, by far the most common; ~18k files)

  • $ANTLR — ANTLR-generated lexers and parsers

  • # This is a generated file. — generated scripts

  • ## Autogenerated — generated Markdown and config

  • // Code generated ... DO NOT EDIT. — go generate output, such as the controller-gen deepcopy and kubebuilder scaffolding under cloud/

These files are overwritten on the next build, so manual edits are lost and only pollute the diff.

Shell Scripts

Shell scripts (*.sh) follow a separate style guide maintained in the liferay-docker repository. Defer their formatting to the format-bash-source skill and the CODE_STYLE.md it depends on. Resolve both files in this order:

  1. Local Checkout — when liferay-docker sits beside this repository, read ../liferay-docker/.claude/skills/format-bash-source/SKILL.md and ../liferay-docker/.claude/CODE_STYLE.md.

  2. Remote Fallback — when the local checkout is absent, download both files from raw.githubusercontent.com and read them from there:

    temp_dir=$(mktemp -d)
    
    curl \
    	--fail \
    	--output "${temp_dir}/format-bash-source.md" \
    	--silent \
    	--url "https://raw.githubusercontent.com/liferay/liferay-docker/refs/heads/master/.claude/skills/format-bash-source/SKILL.md"
    
    curl \
    	--fail \
    	--output "${temp_dir}/CODE_STYLE.md" \
    	--silent \
    	--url "https://raw.githubusercontent.com/liferay/liferay-docker/refs/heads/master/.claude/CODE_STYLE.md"
    

For any *.sh file in scope, read the resolved format-bash-source SKILL.md and the CODE_STYLE.md it points to, then apply those rules.

Go Code

Go files (*.go) are outside the portal source formatter's set of file types, so the automatic formatter gofmt is used instead. The conventions for Go live in .claude/rules/go-style.md, which is scoped to cloud/operator/**/*.go. Read that file and apply it.

The workflow mirrors the one above. Run gofmt across the Go module — the directory that holds go.mod — apply the rules from .claude/rules/go-style.md, then rerun gofmt to absorb any changes. Both the first pass and the rerun are the same command:

cd <go-module-root> && gofmt -w .

List the files that are not yet formatted without rewriting them:

cd <go-module-root> && gofmt -l .

When a rule and gofmt disagree, gofmt wins; leave the formatted code as it stands.

Skip generated Go files. Beyond the marker line listed above, a Go file whose name contains zz_generated is generated output that the next go generate rewrites.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

jira-bug

無料概要あり

不具合の説明や修正コミットから必要事項を整理し、再現手順や期待・実際の動作を含むバグチケットをLPDプロジェクトのJiraに登録できます。

  • LPDの不具合をJiraに登録したいとき
  • 修正コミットからバグを起票したいとき
  • 再現手順と期待動作を整理したいとき
liferay/liferay-portal2,2672026年10月29日 更新

jira-task

無料概要あり

説明やコミット内容をもとに、必要な情報を整えてLPDプロジェクトのJiraにタスクを登録し、チケット番号と閲覧URLを受け取れます。

  • LPDの作業タスクを起票したいとき
  • コミットからタスクを整理したいとき
  • 受け入れ条件付きで課題を登録したいとき
liferay/liferay-portal2,2672026年10月29日 更新

markdown-format

無料概要あり

Liferay向けのMarkdown文書を、前付けの順序や見出しの表記、シェル記法、文章の調子まで整え、リポジトリの規約に沿った読みやすい形に仕上げます。

  • Liferay向けMarkdownを整えたいとき
  • 見出しや前付けを規約に合わせたいとき
  • シェル例と文章を校正したいとき
liferay/liferay-portal2,2672026年10月29日 更新

poshi-migrate

無料概要あり

LiferayのPoshi `.testcase` を内容に応じてPlaywright、Jest、JUnit、Java統合テストへ移行し、既存テストとの重複や移行を妨げる条件も整理します。

  • Poshiテストを新しいテスト層へ移したいとき
  • 既存Playwrightテストとの重複を調べたいとき
  • 移行先と実装手順を計画したいとき
liferay/liferay-portal2,2672026年10月29日 更新

poshi-shrink

無料概要あり

LiferayコンポーネントのPoshiテストを調べ、重複するテストを統合・整理する計画を立ててから、確認しやすい単位でテスト数を減らします。

  • コンポーネントのPoshiテストを減らしたいとき
  • Playwright移行前にテストを整理したいとき
  • 重複テストの統合計画を確認したいとき
liferay/liferay-portal2,2672026年10月29日 更新

pr

無料概要あり

現在のブランチからGitHubのPRを作成し、関連するJiraチケットをレビュー状態に移してPRのURLを記録する手順を進めます。

  • 現在のブランチからPRを作りたいとき
  • コミット内容をPR本文にまとめたいとき
  • JiraチケットにPRを記録したいとき
liferay/liferay-portal2,2672026年10月29日 更新

liferay のスキルをすべて見る

このスキルの問題を報告する