Skip to content
Back to skills

Pf Import Check

ASecurity

Audit PatternFly imports for correctness and bundle-size anti-patterns. Use when imports fail, bundles are bloated, or after upgrading PatternFly versions.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
ai-agentsgobashreactapidocumentation

Works with

  • api

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned September 21, 2026

npx -y skills add rh-uxd/ai-helpers --skill pf-import-check --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pf Import Check?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pf Import Check
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rh-uxd-pf-import-check/badge)](https://www.skillsdirectory.com/skills/rh-uxd-pf-import-check)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pf-import-check
description: Audit PatternFly imports for correctness and bundle-size anti-patterns. Use when imports fail, bundles are bloated, or after upgrading PatternFly versions.
---

# PF Import Checker

Find and report invalid PatternFly import patterns and bundle-size anti-patterns.

## PatternFly API documentation

If PatternFly documentation tools are available, use them to confirm current package paths and import subpaths before flagging. Without documentation available, rely on the import rules and examples in this skill.

## Input

The user provides a file path, directory, or component to check. Default to scanning the project source directory. Adapt search paths to the project structure (`src/`, `app/`, `packages/*/src/`).

## What to check

### Import correctness

1. Charts imported from `@patternfly/react-charts` root (must use `/victory` subpath).
2. Chatbot imports not using `@patternfly/chatbot/dist/dynamic/*`.
3. Component-group imports not using `@patternfly/react-component-groups/dist/dynamic/*`.
4. Missing package CSS imports for features in use.

### Bundle-size anti-patterns

5. **Barrel imports from `@patternfly/react-icons`** — importing from the package root pulls in the entire icon set (~1.8MB per SSR chunk). Each icon must be imported individually from its deep path.
6. **Full CSS bundle import** — importing `@patternfly/patternfly/patternfly.css` or `@patternfly/patternfly/patternfly-base.css` pulls the entire stylesheet. Import only the CSS modules needed: `base.css` + feature-specific CSS (`patternfly-charts.css`, `patternfly-addons.css`).
7. **Duplicate PF module imports** — the same component imported from different paths (e.g., both `@patternfly/react-core` and `@patternfly/react-core/dist/esm/...`) inflates the bundle with duplicate modules.

## Validation commands

```bash
# Import correctness
rg "@patternfly/react-charts['\"]" <source-dir>
rg "@patternfly/chatbot['\"]" <source-dir>
rg "@patternfly/react-component-groups['\"]" <source-dir>

# Bundle-size anti-patterns
rg "from ['\"]@patternfly/react-icons['\"]" <source-dir>
rg "patternfly\.css|patternfly-base\.css" <source-dir>
rg "@patternfly/react-core/dist/" <source-dir>
```

## Correct import examples

```tsx
// Charts — use /victory subpath
import { ChartDonut } from "@patternfly/react-charts/victory";

// Chatbot — use /dist/dynamic/ subpath
import { Chatbot } from "@patternfly/chatbot/dist/dynamic/Chatbot";

// Component groups — use /dist/dynamic/ subpath
import { BulkSelect } from "@patternfly/react-component-groups/dist/dynamic/BulkSelect";
```

### Icon imports

```tsx
// Bad — barrel import pulls entire icon set (~1.8MB)
import { CogIcon, BellIcon } from "@patternfly/react-icons";

// Good — deep imports, tree-shakeable
import CogIcon from "@patternfly/react-icons/dist/dynamic/icons/cog-icon";
import BellIcon from "@patternfly/react-icons/dist/dynamic/icons/bell-icon";
```

### CSS imports

```tsx
// Bad — pulls entire PF stylesheet
import "@patternfly/patternfly/patternfly.css";

// Good — base + only what you need
import "@patternfly/react-core/dist/styles/base.css";
import "@patternfly/patternfly/patternfly-charts.css";      // only if using charts
import "@patternfly/chatbot/dist/css/main.css";              // only if using chatbot
import "@patternfly/react-component-groups/dist/css/main.css"; // only if using component groups
```

## Rules

- Report barrel icon imports as high severity — they are the single largest contributor to PF bundle bloat
- Report full CSS imports as medium severity — wasteful but less impactful than icon barrels
- Report duplicate module imports as low severity — often accidental, usually fixable by updating one import path
- When a file has both correctness and bundle issues, report correctness first
- Do not flag `@patternfly/react-core` barrel imports — this package is designed for tree-shaking and barrel imports are the correct pattern
- Do not flag `@patternfly/react-table` barrel imports — same as react-core, tree-shakeable by design

## Output format

For each finding, provide:

- **Severity**: high | medium | low
- **File path** and line number
- **Current import** — the offending line
- **Suggested fix** — the corrected import
- **Impact** — estimated bundle size reduction or explanation of why this matters

Group findings by severity (high first). End with a summary count: `Found N import issues: X high, Y medium, Z low.`

Files in this skill

  • SKILL.md1.2 KB
  • eval/cases/invalid-charts-import/ChartsDashboard.tsx704 B
  • eval/cases/invalid-charts-import/annotations.yaml153 B
  • eval/cases/invalid-charts-import/input.yaml106 B
  • eval/cases/invalid-chatbot-import/AssistantPanel.tsx782 B
  • eval/cases/invalid-chatbot-import/annotations.yaml149 B
  • eval/cases/invalid-chatbot-import/input.yaml99 B
  • eval/cases/valid-pf6-imports/SettingsPage.tsx1.1 KB
  • eval/cases/valid-pf6-imports/annotations.yaml25 B
  • eval/cases/valid-pf6-imports/input.yaml102 B
  • eval/eval.yaml2.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.