Skip to content

chore: provide LLM instructions in starters #7729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

wmertens
Copy link
Member

We should provide instructions that help LLMs trained on React code to write good Qwik code.

Here is a start.

@wmertens wmertens requested a review from a team as a code owner July 15, 2025 09:46
Copy link

changeset-bot bot commented Jul 15, 2025

⚠️ No Changeset found

Latest commit: bf17bd4

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

Copy link
Member

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Great idea 👌
We should provide few code snippets side by side to improve the LLM prompt and get an accurate response

Copy link

pkg-pr-new bot commented Jul 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@builder.io/qwik@7729
npm i https://pkg.pr.new/@builder.io/qwik-city@7729
npm i https://pkg.pr.new/eslint-plugin-qwik@7729
npm i https://pkg.pr.new/create-qwik@7729

commit: 4d35e17

Copy link
Contributor

github-actions bot commented Jul 15, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview bf17bd4

@wzhouwzhou
Copy link

As discussed, we'll want to include specification of any tendency/misunderstanding of the LLM for proxy in a proxy (i.e., avoid creating stores within stores). And for the v2 instructions that useSerializer$ / hydration approach (where otherwise LLMs lose "scope" of noSerialize objects from server to clientside).

- Instead of `useReducer()`, use `useSignal()` or `useStore()`.
- Instead of `useMemo()`, use `useComputed$()`.
- For context, use `createContextId()`, `useContextProvider()`, and `useContext()`. You can `useContext()` in the same component that first provides the context.
- Instead of `useEffect()` and `useLayoutEffect()`, use `useTask$()` or `useVisibleTask$()`.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are more cases that these two :

  • useTask$ as a general rule of thumb
  • useVisibleTask$ if it needs to track state or cleanup
  • useOnDocument('qvisible`) if it needs to run a side effect on the client once

- Exception: if you need to read `children` you can use an "Inline Component" which is a non-wrapped Component. This removes access to hooks, and disables automatic code splitting.
- Prefer to put the props type after the first argument of the component function, either inline or in a separate interface. This makes it easier to switch between inline and wrapped components.
- Event handlers always use `...$()` suffix for lazy loading. For example `onClick$={() => { ... }}`. In general, DOM events are to be handled with `onEventName$={(ev, el) => { ... }}`, where `ev` is the event object and `el` is the element that triggered the event.
- Event handlers are called async when they are not loaded yet and sync otherwise. This means that `ev.preventDefault()` will not always work. So instead, use the attributes `preventdefault:eventname` and `stoppropagation:eventname` to prevent the default behavior and stop the event from bubbling up. For example `preventdefault:click` to prevent the default click behavior and `stoppropagation:click` to stop the click event from bubbling up.
Copy link
Contributor

Choose a reason for hiding this comment

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

If you need logic to preventdefault an event use sync$ for example to prevent default ArrowUp and ArrowDown keyboard event, but not the rest.

- `useComputed$()` - Reactive computed values. This is the preferred way to derive values from state.
- `useResource$()` - Async data fetching.
- `useTask$()` - Side effects and lifecycle.
- `useVisibleTask$()` - Side effects and lifecycle. Use this to run side effects that are not possible to run on the server, but be aware that it can slow down the initial load. Consider passing `{strategy: 'document-idle'}` to run it after the page is loaded.
Copy link
Contributor

Choose a reason for hiding this comment

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

Use useOnDocument('qvisible') if you only need to run a one time side effect when the component because visible

address: { ...initialState.address },
});
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add useOn, useOnDocument, useOnWindow and sync$

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.

5 participants