From kibana-dev-workflow-tools
Runs scoped eslint --fix and type_check on changed files before committing to prevent CI failures. Use before git commit, git push, or when the user asks to lint, type-check, or validate changes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/kibana-dev-workflow-tools:kibana-precommit-checksThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Run eslint and type_check scoped to only the changed files before committing/pushing. Catches lint and type errors locally instead of waiting 45+ minutes for CI to report them.
Run eslint and type_check scoped to only the changed files before committing/pushing. Catches lint and type errors locally instead of waiting 45+ minutes for CI to report them.
git commit or git push# Get all changed .ts/.tsx files (staged + unstaged + untracked)
CHANGED_TS=$(comm -23 \
<(sort -u <(git diff --name-only HEAD; git diff --cached --name-only; git ls-files --others --exclude-standard) | grep -E '\.(tsx?|jsx?)$') \
<(echo ""))
# Find unique tsconfig.json projects that own the changed files.
# Walk up from each file to the nearest directory containing a tsconfig.json.
PROJECTS=$(echo "$CHANGED_TS" | while read -r f; do
dir=$(dirname "$f")
while [ "$dir" != "." ] && [ "$dir" != "/" ]; do
if [ -f "$dir/tsconfig.json" ]; then
echo "$dir/tsconfig.json"
break
fi
dir=$(dirname "$dir")
done
done | sort -u)
CHANGED_FILES=$(git diff --name-only HEAD; git diff --cached --name-only)
if [ -n "$CHANGED_FILES" ]; then
node scripts/eslint --fix $CHANGED_FILES
fi
If eslint fails with Cannot find module '@kbn/setup-node-env', you need to run yarn kbn bootstrap first. If bootstrap is not practical (e.g., worktree without full setup), skip eslint and rely on CI — but still run the type check.
For each unique tsconfig project found in Step 1, run a separate type check:
for project in $PROJECTS; do
echo "=== Type checking: $project ==="
node scripts/type_check --project "$project" --cleanup
# Exit early on first failure to save time
if [ $? -ne 0 ]; then
echo "FAILED: $project"
break
fi
done
Critical flags:
--project <path> — scopes the check to one tsconfig project (fast: seconds instead of 30+ minutes)--cleanup — removes the temporary tsconfig.type_check.json files after the run so they don't pollute the working tree or show up in git statusWhat --cleanup prevents:
Without --cleanup, the type checker leaves behind tsconfig.type_check.json and tsconfig.refs.json files in every project directory. These are gitignored (*.type_check.json in .gitignore) so they won't be committed, but they clutter the workspace. The --cleanup flag deletes them after the run.
About target/types/ directories:
The type checker emits .d.ts files into target/types/ under each project. These are gitignored (under target/) and are used as a build cache for subsequent runs. They are harmless and make future type checks faster. Do NOT delete them manually unless you want a clean-cache run (--clean-cache).
# If eslint made changes, stage them
git diff --name-only | xargs -r git add
Then proceed with the commit.
| Scenario | Command |
|---|---|
| Type check one project | node scripts/type_check --project x-pack/platform/plugins/shared/fleet/tsconfig.json --cleanup |
| Type check all (slow) | node scripts/type_check |
| ESLint changed files | node scripts/eslint --fix $(git diff --name-only HEAD) |
| Clean type cache | node scripts/type_check --clean-cache |
Each Kibana module has a tsconfig.json at its root. Test files are typically included by the parent plugin's tsconfig via include globs (e.g., "test/scout/**/*"). To find which tsconfig owns a file:
tsconfig.jsoninclude array covers the filenode scripts/lint_ts_projects to see ownership errorsCommon examples:
x-pack/platform/plugins/shared/fleet/test/scout/** → x-pack/platform/plugins/shared/fleet/tsconfig.jsonx-pack/platform/plugins/shared/osquery/test/scout_osquery/** → x-pack/platform/plugins/shared/osquery/tsconfig.jsonsrc/platform/plugins/shared/dashboard/test/scout/** → src/platform/plugins/shared/dashboard/tsconfig.json--project accepts only ONE tsconfig per run. For changes spanning multiple plugins, run separate commands.@kbn/setup-node-env — if you get module errors, run yarn kbn bootstrap.npx claudepluginhub patrykkopycinski/patryks-treadmill-claude-plugins --plugin kibana-dev-workflow-toolsCreates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.