Skip to content

chore: add migrate-component skill for promoting shared template components#2099

Open
Adi-204 wants to merge 2 commits into
asyncapi:masterfrom
Adi-204:issue-2098-handleerror-migration-skill
Open

chore: add migrate-component skill for promoting shared template components#2099
Adi-204 wants to merge 2 commits into
asyncapi:masterfrom
Adi-204:issue-2098-handleerror-migration-skill

Conversation

@Adi-204
Copy link
Copy Markdown
Member

@Adi-204 Adi-204 commented May 23, 2026

Description
Codifies the workflow for moving a duplicated React/JSX component out of a template-local components/ directory into the shared@asyncapi/generator-components package. The skill captures the preconditions (two-template threshold, naming-collision check), the research artifacts (file list, props table, union signature) and the ten-step execution flow (author, export, test, snapshot, delete, update consumers, regenerate integration snapshots, diff, regenerate api_components.md, full test/lint), with references to canonical examples already in the repo. Validated end-to-end against the duplicated HandleError component across the python, dart, and java/quarkus websocket clients — integration snapshots unchanged across all four clients

Related issue(s)
Fixes #2098

Summary by CodeRabbit

  • New Features

    • Added a shared, language-aware error handling component and switched templates to use it (Python, Dart, Java/Quarkus).
  • Documentation

    • Published API docs and usage examples for the new error handler; updated contributor guidance for component testing.
  • Tests

    • Added snapshot tests covering multiple languages and error/validation cases.

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 23, 2026

⚠️ No Changeset found

Latest commit: 155deec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@asyncapi-bot
Copy link
Copy Markdown
Contributor

What reviewer looks at during PR review

The following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.

  1. PR Title: Use a concise title that follows our Conventional Commits guidelines and clearly summarizes the change using imperative mood (it means spoken or written as if giving a command or instruction, like "add new helper for listing operations")

    Note - In Generator, prepend feat: or fix: in PR title only when PATCH/MINOR release must be triggered.

  2. PR Description: Clearly explain the issue being solved, summarize the changes made, and mention the related issue.

    Note - In Generator, we use Maintainers Work board to track progress. Ensure the PR Description includes Resolves #<issue-number> or Fixes #<issue-number> this will automatically close the linked issue when the PR is merged and helps automate the maintainers workflow.

  3. Documentation: Update the relevant Generator documentation to accurately reflect the changes introduced in the PR, ensuring users and contributors have up-to-date guidance.

  4. Comments and JSDoc: Write clear and consistent JSDoc comments for functions, including parameter types, return values, and error conditions, so others can easily understand and use the code.

  5. DRY Code: Ensure the code follows the Don't Repeat Yourself principle. Look out for duplicate logic that can be reused.

  6. Test Coverage: Ensure the new code is well-tested with meaningful test cases that pass consistently and cover all relevant edge cases.

  7. Commit History: Contributors should avoid force-pushing as much as possible. It makes it harder to track incremental changes and review the latest updates.

  8. Template Design Principles Alignment: While reviewing template-related changes in the packages/ directory, ensure they align with the Assumptions and Principles. If any principle feels outdated or no longer applicable, start a discussion these principles are meant to evolve with the project.

  9. Reduce Scope When Needed: If an issue or PR feels too large or complex, consider splitting it and creating follow-up issues. Smaller, focused PRs are easier to review and merge.

  10. Bot Comments: As reviewers, check that contributors have appropriately addressed comments or suggestions made by automated bots. If there are bot comments the reviewer disagrees with, react to them or mark them as resolved, so the review history remains clear and accurate.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 57bbf777-399b-463c-add0-549e9aa5ddcc

📥 Commits

Reviewing files that changed from the base of the PR and between 0be3fb7 and 155deec.

📒 Files selected for processing (3)
  • .claude/skills/migrate-component/SKILL.md
  • AGENTS.md
  • packages/components/src/components/HandleError.js
✅ Files skipped from review due to trivial changes (2)
  • AGENTS.md
  • .claude/skills/migrate-component/SKILL.md

📝 Walkthrough

Walkthrough

Consolidates the HandleError component from three duplicated template-local implementations (Dart, Java/Quarkus, Python) into a single shared, language/framework-parameterized component in @asyncapi/generator-components, with language-specific template bodies, validation, tests, and API documentation.

Changes

HandleError Component Consolidation

Layer / File(s) Summary
migrate-component CLAUDE skill documentation
.claude/skills/migrate-component/SKILL.md
Procedural guide for migrating duplicated template-local components into the shared package, including preconditions, research/design phases, execution checkpoints, and validation steps.
HandleError shared component implementation
packages/components/src/components/HandleError.js, packages/components/src/index.js
Centralizes language/framework-specific error-handler template bodies in handleErrorConfig, adds resolveHandleErrorBlock helper to select the correct template, implements the HandleError component with language/framework validation, and exports it from the package entrypoint.
HandleError component tests and contributor guidance
packages/components/test/components/HandleError.test.js, AGENTS.md
Snapshot tests for rendered output across supported language/framework combinations (Python, Dart, Java/Quarkus); negative tests for unsupported languages and missing/unknown frameworks. AGENTS.md updated to require snapshot tests and clarify when fixtures are needed.
API documentation for HandleError
apps/generator/docs/api_components.md
Adds HandleError to the components API table of contents and documents its purpose, props (language, framework), return type, and usage example.
Template consumer migrations
packages/templates/clients/websocket/dart/components/ClientClass.js, packages/templates/clients/websocket/java/quarkus/components/EchoWebSocket.js, packages/templates/clients/websocket/python/components/ClientClass.js
Three templates updated to import HandleError from @asyncapi/generator-components and render it with explicit language prop (plus framework prop for Java/Quarkus); template-local HandleError.js files removed from those directories.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • asyncapi/generator#2095: Both PRs involve the Dart WebSocket HandleError generation; #2095 introduces the template-local Dart HandleError and wires OnError callback, while this PR removes that template-local component in favor of the shared @asyncapi/generator-components variant.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows Conventional Commits format (chore:) and clearly summarizes the main change: adding a migrate-component skill document.
Linked Issues check ✅ Passed The PR fully implements the requirements from issue #2098: a reusable skill document for migrating duplicated components (HandleError) to the shared package, with end-to-end proof of concept.
Out of Scope Changes check ✅ Passed All changes directly support the migration skill objective: the skill document itself, the new HandleError shared component, tests, documentation updates, and template consumer updates using the shared component.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@asyncapi-bot
Copy link
Copy Markdown
Contributor

asyncapi-bot commented May 23, 2026

🚀 Docs preview deployed
Below link points directly to the generator docs preview. May the force be with you!
https://6a12ad220271c40aaf7492a1--asyncapi-website.netlify.app/docs/tools/generator

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/skills/migrate-component/SKILL.md:
- Line 9: Update the path pattern used in this migration instruction: replace
the literal "packages/templates/clients/<protocol>/<lang>/components/"
occurrences in SKILL.md with a generic, recursive pattern such as
"packages/templates/clients/<protocol>/<templatePath...>/components/" so
multi-level framework/language folders (e.g., java/quarkus/components) are
matched; ensure every later step in the file reuses that same
"<protocol>/<templatePath...>/components" shape so downstream commands and
examples operate on the correct, generic source path.
- Around line 145-146: The current search example using grep -rn "from
'./<Component>'" is too strict and misses other valid import forms; update the
instructions in SKILL.md to recommend a regex-based search that matches both
single and double quotes and flexible spacing (e.g., a pattern matching
from\s+['"]\./<Component>['"]), and mention using grep -P or ripgrep (rg) with
that regex so imports like from "./<Component>" or from'./<Component>' and
variants are found; reference the exact string being replaced ("from
'./<Component>'") and the file section containing the example so reviewers can
locate and replace it.

In `@packages/components/src/components/HandleError.js`:
- Around line 80-96: The JSDoc for the exported HandleError function is missing
`@throws` tags for the errors it can raise; update the comment above export
function HandleError({ language, framework = '' }) to include `@throws` entries
that describe each thrown condition (e.g., invalid or unsupported language,
invalid/unsupported framework) and the type of error thrown so callers know what
to catch; reference the function name HandleError and the parameters language
and framework in the descriptions.

In `@packages/components/test/components/HandleError.test.js`:
- Around line 5-23: Add an integration snapshot test that renders the
HandleError component using a real AsyncAPI fixture: require a fixture JSON from
the test fixtures directory, wrap HandleError in the same AsyncAPI
context/provider your app uses (or pass the relevant parsed AsyncAPI
document/operation props), call render(...) and
expect(result.trim()).toMatchSnapshot(); name the test something like "renders
HandleError with real AsyncAPI fixture (integration snapshot)". Ensure you
import the same helper render function used by other tests and reference the
HandleError component so the new test sits alongside the existing unit
snapshots.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9b3d24f8-d9a3-4a3c-a957-df9511bfd3b2

📥 Commits

Reviewing files that changed from the base of the PR and between 917a555 and 0be3fb7.

⛔ Files ignored due to path filters (1)
  • packages/components/test/components/__snapshots__/HandleError.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (11)
  • .claude/skills/migrate-component/SKILL.md
  • apps/generator/docs/api_components.md
  • packages/components/src/components/HandleError.js
  • packages/components/src/index.js
  • packages/components/test/components/HandleError.test.js
  • packages/templates/clients/websocket/dart/components/ClientClass.js
  • packages/templates/clients/websocket/dart/components/HandleError.js
  • packages/templates/clients/websocket/java/quarkus/components/EchoWebSocket.js
  • packages/templates/clients/websocket/java/quarkus/components/HandleError.js
  • packages/templates/clients/websocket/python/components/ClientClass.js
  • packages/templates/clients/websocket/python/components/HandleError.js
💤 Files with no reviewable changes (3)
  • packages/templates/clients/websocket/java/quarkus/components/HandleError.js
  • packages/templates/clients/websocket/dart/components/HandleError.js
  • packages/templates/clients/websocket/python/components/HandleError.js

Comment thread .claude/skills/migrate-component/SKILL.md Outdated
Comment thread .claude/skills/migrate-component/SKILL.md Outdated
Comment thread packages/components/src/components/HandleError.js
Comment thread packages/components/test/components/HandleError.test.js
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration of HandleError component with the help of new claude skill as POC

2 participants