liferay/liferay-portal / .claude/skills/format-source
format-source
VerifiedFormat source files to align with Liferay's coding standards.
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 generateoutput, such as the controller-gen deepcopy and kubebuilder scaffolding undercloud/
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:
-
Local Checkout — when
liferay-dockersits beside this repository, read../liferay-docker/.claude/skills/format-bash-source/SKILL.mdand../liferay-docker/.claude/CODE_STYLE.md. -
Remote Fallback — when the local checkout is absent, download both files from
raw.githubusercontent.comand 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.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |