@dianzhong/create-harness-app 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +412 -0
- package/package.json +29 -0
- package/templates/axios/.env.example +2 -0
- package/templates/axios/src/api/auth.ts +19 -0
- package/templates/axios/src/api/request.ts +61 -0
- package/templates/axios/src/types/api.ts +26 -0
- package/templates/axios/src/utils/auth.ts +5 -0
- package/templates/axios/src/utils/storage.ts +17 -0
- package/templates/harness/full/.agents/skills/find-skills/SKILL.md +143 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/LICENSE.md +21 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/SKILL.md +155 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/SYNC.md +5 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/animation-class-based-technique.md +258 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/animation-state-driven-technique.md +287 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-async.md +99 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-data-flow.md +313 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-fallthrough-attrs.md +179 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-keep-alive.md +139 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-slots.md +226 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-suspense.md +231 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-teleport.md +110 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-transition-group.md +131 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/component-transition.md +135 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/composables.md +303 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/directives.md +168 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/perf-avoid-component-abstraction-in-lists.md +177 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/perf-v-once-v-memo-directives.md +185 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/perf-virtualize-large-lists.md +182 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/plugins.md +178 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/reactivity.md +371 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/render-functions.md +227 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/sfc.md +355 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/state-management.md +138 -0
- package/templates/harness/full/.agents/skills/vue-best-practices/references/updated-hook-performance.md +193 -0
- package/templates/harness/full/.claude/agents/code-reviewer.md +109 -0
- package/templates/harness/full/.claude/agents/harness-reviewer.md +51 -0
- package/templates/harness/full/.claude/hooks/guard-tool.cjs +234 -0
- package/templates/harness/full/.claude/hooks/notify.cjs +168 -0
- package/templates/harness/full/.claude/hooks/quality-gate.cjs +135 -0
- package/templates/harness/full/.claude/rules/delivery.md +66 -0
- package/templates/harness/full/.claude/rules/formatting.md +7 -0
- package/templates/harness/full/.claude/rules/git.md +8 -0
- package/templates/harness/full/.claude/rules/skills-mcp.md +13 -0
- package/templates/harness/full/.claude/rules/vue.md +227 -0
- package/templates/harness/full/.claude/settings.json +123 -0
- package/templates/harness/full/.claude/skills/find-skills/SKILL.md +143 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/LICENSE.md +21 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/SKILL.md +155 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/SYNC.md +5 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/animation-class-based-technique.md +258 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/animation-state-driven-technique.md +287 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-async.md +99 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-data-flow.md +313 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-fallthrough-attrs.md +179 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-keep-alive.md +139 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-slots.md +226 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-suspense.md +231 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-teleport.md +110 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-transition-group.md +131 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/component-transition.md +135 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/composables.md +303 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/directives.md +168 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/perf-avoid-component-abstraction-in-lists.md +177 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/perf-v-once-v-memo-directives.md +185 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/perf-virtualize-large-lists.md +182 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/plugins.md +178 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/reactivity.md +371 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/render-functions.md +227 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/sfc.md +355 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/state-management.md +138 -0
- package/templates/harness/full/.claude/skills/vue-best-practices/references/updated-hook-performance.md +193 -0
- package/templates/harness/full/.editorconfig +8 -0
- package/templates/harness/full/.husky/commit-msg +1 -0
- package/templates/harness/full/.husky/pre-commit +1 -0
- package/templates/harness/full/.lintstagedrc.json +4 -0
- package/templates/harness/full/.nvmrc +1 -0
- package/templates/harness/full/.oxlintrc.json +11 -0
- package/templates/harness/full/.prettierrc.json +6 -0
- package/templates/harness/full/AGENTS.md +3 -0
- package/templates/harness/full/CLAUDE.md +28 -0
- package/templates/harness/full/GEMINI.md +3 -0
- package/templates/harness/full/commitlint.config.ts +3 -0
- package/templates/harness/full/docs/ai-harness.md +77 -0
- package/templates/harness/full/docs/delivery-template.md +66 -0
- package/templates/harness/full/docs/git.md +24 -0
- package/templates/harness/full/docs/harness-quick-reference.md +89 -0
- package/templates/harness/full/docs/review-checklist.md +49 -0
- package/templates/harness/full/scripts/harness-hooks.test.mjs +218 -0
- package/templates/harness/full/scripts/verify-skills.mjs +248 -0
- package/templates/harness/full/scripts/verify-skills.test.mjs +72 -0
- package/templates/harness/full/skills-lock.json +50 -0
- package/templates/harness/minimal/.claude/hooks/guard-tool.cjs +234 -0
- package/templates/harness/minimal/.claude/hooks/quality-gate.cjs +135 -0
- package/templates/harness/minimal/.claude/settings.json +27 -0
- package/templates/harness/minimal/CLAUDE.md +12 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: find-skills
|
|
3
|
+
description: Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Find Skills
|
|
7
|
+
|
|
8
|
+
This skill helps you discover and install skills from the open agent skills ecosystem.
|
|
9
|
+
|
|
10
|
+
## When to Use This Skill
|
|
11
|
+
|
|
12
|
+
Use this skill when the user:
|
|
13
|
+
|
|
14
|
+
- Asks "how do I do X" where X might be a common task with an existing skill
|
|
15
|
+
- Says "find a skill for X" or "is there a skill for X"
|
|
16
|
+
- Asks "can you do X" where X is a specialized capability
|
|
17
|
+
- Expresses interest in extending agent capabilities
|
|
18
|
+
- Wants to search for tools, templates, or workflows
|
|
19
|
+
- Mentions they wish they had help with a specific domain (design, testing, deployment, etc.)
|
|
20
|
+
|
|
21
|
+
## What is the Skills CLI?
|
|
22
|
+
|
|
23
|
+
The Skills CLI (`npx skills`) is the package manager for the open agent skills ecosystem. Skills are modular packages that extend agent capabilities with specialized knowledge, workflows, and tools.
|
|
24
|
+
|
|
25
|
+
**Key commands:**
|
|
26
|
+
|
|
27
|
+
- `npx skills find [query]` - Search for skills interactively or by keyword
|
|
28
|
+
- `npx skills add <package>` - Install a skill from GitHub or other sources
|
|
29
|
+
- `npx skills check` - Check for skill updates
|
|
30
|
+
- `npx skills update` - Update all installed skills
|
|
31
|
+
|
|
32
|
+
**Browse skills at:** https://skills.sh/
|
|
33
|
+
|
|
34
|
+
## How to Help Users Find Skills
|
|
35
|
+
|
|
36
|
+
### Step 1: Understand What They Need
|
|
37
|
+
|
|
38
|
+
When a user asks for help with something, identify:
|
|
39
|
+
|
|
40
|
+
1. The domain (e.g., React, testing, design, deployment)
|
|
41
|
+
2. The specific task (e.g., writing tests, creating animations, reviewing PRs)
|
|
42
|
+
3. Whether this is a common enough task that a skill likely exists
|
|
43
|
+
|
|
44
|
+
### Step 2: Check the Leaderboard First
|
|
45
|
+
|
|
46
|
+
Before running a CLI search, check the [skills.sh leaderboard](https://skills.sh/) to see if a well-known skill already exists for the domain. The leaderboard ranks skills by total installs, surfacing the most popular and battle-tested options.
|
|
47
|
+
|
|
48
|
+
For example, top skills for web development include:
|
|
49
|
+
|
|
50
|
+
- `vercel-labs/agent-skills` — React, Next.js, web design (100K+ installs each)
|
|
51
|
+
- `anthropics/skills` — Frontend design, document processing (100K+ installs)
|
|
52
|
+
|
|
53
|
+
### Step 3: Search for Skills
|
|
54
|
+
|
|
55
|
+
If the leaderboard doesn't cover the user's need, run the find command:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx skills find [query]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For example:
|
|
62
|
+
|
|
63
|
+
- User asks "how do I make my React app faster?" → `npx skills find react performance`
|
|
64
|
+
- User asks "can you help me with PR reviews?" → `npx skills find pr review`
|
|
65
|
+
- User asks "I need to create a changelog" → `npx skills find changelog`
|
|
66
|
+
|
|
67
|
+
### Step 4: Verify Quality Before Recommending
|
|
68
|
+
|
|
69
|
+
**Do not recommend a skill based solely on search results.** Always verify:
|
|
70
|
+
|
|
71
|
+
1. **Install count** — Prefer skills with 1K+ installs. Be cautious with anything under 100.
|
|
72
|
+
2. **Source reputation** — Official sources (`vercel-labs`, `anthropics`, `microsoft`) are more trustworthy than unknown authors.
|
|
73
|
+
3. **GitHub stars** — Check the source repository. A skill from a repo with <100 stars should be treated with skepticism.
|
|
74
|
+
|
|
75
|
+
### Step 5: Present Options to the User
|
|
76
|
+
|
|
77
|
+
When you find relevant skills, present them to the user with:
|
|
78
|
+
|
|
79
|
+
1. The skill name and what it does
|
|
80
|
+
2. The install count and source
|
|
81
|
+
3. The install command they can run
|
|
82
|
+
4. A link to learn more at skills.sh
|
|
83
|
+
|
|
84
|
+
Example response:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
I found a skill that might help! The "react-best-practices" skill provides
|
|
88
|
+
React and Next.js performance optimization guidelines from Vercel Engineering.
|
|
89
|
+
(185K installs)
|
|
90
|
+
|
|
91
|
+
To install it:
|
|
92
|
+
npx skills add vercel-labs/agent-skills@react-best-practices
|
|
93
|
+
|
|
94
|
+
Learn more: https://skills.sh/vercel-labs/agent-skills/react-best-practices
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Step 6: Offer to Install
|
|
98
|
+
|
|
99
|
+
If the user wants to proceed, you can install the skill for them:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx skills add <owner/repo@skill> -g -y
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The `-g` flag installs globally (user-level) and `-y` skips confirmation prompts.
|
|
106
|
+
|
|
107
|
+
## Common Skill Categories
|
|
108
|
+
|
|
109
|
+
When searching, consider these common categories:
|
|
110
|
+
|
|
111
|
+
| Category | Example Queries |
|
|
112
|
+
| --------------- | ---------------------------------------- |
|
|
113
|
+
| Web Development | react, nextjs, typescript, css, tailwind |
|
|
114
|
+
| Testing | testing, jest, playwright, e2e |
|
|
115
|
+
| DevOps | deploy, docker, kubernetes, ci-cd |
|
|
116
|
+
| Documentation | docs, readme, changelog, api-docs |
|
|
117
|
+
| Code Quality | review, lint, refactor, best-practices |
|
|
118
|
+
| Design | ui, ux, design-system, accessibility |
|
|
119
|
+
| Productivity | workflow, automation, git |
|
|
120
|
+
|
|
121
|
+
## Tips for Effective Searches
|
|
122
|
+
|
|
123
|
+
1. **Use specific keywords**: "react testing" is better than just "testing"
|
|
124
|
+
2. **Try alternative terms**: If "deploy" doesn't work, try "deployment" or "ci-cd"
|
|
125
|
+
3. **Check popular sources**: Many skills come from `vercel-labs/agent-skills` or `ComposioHQ/awesome-claude-skills`
|
|
126
|
+
|
|
127
|
+
## When No Skills Are Found
|
|
128
|
+
|
|
129
|
+
If no relevant skills exist:
|
|
130
|
+
|
|
131
|
+
1. Acknowledge that no existing skill was found
|
|
132
|
+
2. Offer to help with the task directly using your general capabilities
|
|
133
|
+
3. Suggest the user could create their own skill with `npx skills init`
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
I searched for skills related to "xyz" but didn't find any matches.
|
|
139
|
+
I can still help you with this task directly! Would you like me to proceed?
|
|
140
|
+
|
|
141
|
+
If this is something you do often, you could create your own skill:
|
|
142
|
+
npx skills init my-xyz-skill
|
|
143
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 hyf0, SerKo <https://github.com/serkodev>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vue-best-practices
|
|
3
|
+
description: MUST be used for Vue.js tasks. Strongly recommends Composition API with `<script setup>` and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: github.com/vuejs-ai
|
|
7
|
+
version: '18.0.0'
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Vue Best Practices Workflow
|
|
11
|
+
|
|
12
|
+
Use this skill as an instruction set. Follow the workflow in order unless the user explicitly asks for a different order.
|
|
13
|
+
|
|
14
|
+
## Core Principles
|
|
15
|
+
|
|
16
|
+
- **Keep state predictable:** one source of truth, derive everything else.
|
|
17
|
+
- **Make data flow explicit:** Props down, Events up for most cases.
|
|
18
|
+
- **Favor small, focused components:** easier to test, reuse, and maintain.
|
|
19
|
+
- **Avoid unnecessary re-renders:** use computed properties and watchers wisely.
|
|
20
|
+
- **Readability counts:** write clear, self-documenting code.
|
|
21
|
+
|
|
22
|
+
## 1) Confirm architecture before coding (required)
|
|
23
|
+
|
|
24
|
+
- Default stack: Vue 3 + Composition API + `<script setup lang="ts">`.
|
|
25
|
+
- If the project explicitly uses Options API, load `vue-options-api-best-practices` skill if available.
|
|
26
|
+
- If the project explicitly uses JSX, load `vue-jsx-best-practices` skill if available.
|
|
27
|
+
|
|
28
|
+
### 1.1 Must-read core references (required)
|
|
29
|
+
|
|
30
|
+
- Before implementing any Vue task, make sure to read and apply these core references:
|
|
31
|
+
- `references/reactivity.md`
|
|
32
|
+
- `references/sfc.md`
|
|
33
|
+
- `references/component-data-flow.md`
|
|
34
|
+
- `references/composables.md`
|
|
35
|
+
- Keep these references in active working context for the entire task, not only when a specific issue appears.
|
|
36
|
+
|
|
37
|
+
### 1.2 Plan component boundaries before coding (required)
|
|
38
|
+
|
|
39
|
+
Create a brief component map before implementation for any non-trivial feature.
|
|
40
|
+
|
|
41
|
+
- Define each component's single responsibility in one sentence.
|
|
42
|
+
- Keep entry/root and route-level view components as composition surfaces by default.
|
|
43
|
+
- Move feature UI and feature logic out of entry/root/view components unless the task is intentionally a tiny single-file demo.
|
|
44
|
+
- Define props/emits contracts for each child component in the map.
|
|
45
|
+
- Prefer a feature folder layout (`components/<feature>/...`, `composables/use<Feature>.ts`) when adding more than one component.
|
|
46
|
+
|
|
47
|
+
## 2) Apply essential Vue foundations (required)
|
|
48
|
+
|
|
49
|
+
These are essential, must-know foundations. Apply all of them in every Vue task using the core references already loaded in section `1.1`.
|
|
50
|
+
|
|
51
|
+
### Reactivity
|
|
52
|
+
|
|
53
|
+
- Must-read reference from `1.1`: [reactivity](references/reactivity.md)
|
|
54
|
+
- Keep source state minimal (`ref`/`reactive`), derive everything possible with `computed`.
|
|
55
|
+
- Use watchers for side effects if needed.
|
|
56
|
+
- Avoid recomputing expensive logic in templates.
|
|
57
|
+
|
|
58
|
+
### SFC structure and template safety
|
|
59
|
+
|
|
60
|
+
- Must-read reference from `1.1`: [sfc](references/sfc.md)
|
|
61
|
+
- Keep SFC sections in this order: `<script>` → `<template>` → `<style>`.
|
|
62
|
+
- Keep SFC responsibilities focused; split large components.
|
|
63
|
+
- Keep templates declarative; move branching/derivation to script.
|
|
64
|
+
- Apply Vue template safety rules (`v-html`, list rendering, conditional rendering choices).
|
|
65
|
+
|
|
66
|
+
### Keep components focused
|
|
67
|
+
|
|
68
|
+
Split a component when it has **more than one clear responsibility** (e.g. data orchestration + UI, or multiple independent UI sections).
|
|
69
|
+
|
|
70
|
+
- Prefer **smaller components + composables** over one “mega component”
|
|
71
|
+
- Move **UI sections** into child components (props in, events out).
|
|
72
|
+
- Move **state/side effects** into composables (`useXxx()`).
|
|
73
|
+
|
|
74
|
+
Apply objective split triggers. Split the component if **any** condition is true:
|
|
75
|
+
|
|
76
|
+
- It owns both orchestration/state and substantial presentational markup for multiple sections.
|
|
77
|
+
- It has 3+ distinct UI sections (for example: form, filters, list, footer/status).
|
|
78
|
+
- A template block is repeated or could become reusable (item rows, cards, list entries).
|
|
79
|
+
|
|
80
|
+
Entry/root and route view rule:
|
|
81
|
+
|
|
82
|
+
- Keep entry/root and route view components thin: app shell/layout, provider wiring, and feature composition.
|
|
83
|
+
- Do not place full feature implementations in entry/root/view components when those features contain independent parts.
|
|
84
|
+
- For CRUD/list features (todo, table, catalog, inbox), split at least into:
|
|
85
|
+
- feature container component
|
|
86
|
+
- input/form component
|
|
87
|
+
- list (and/or item) component
|
|
88
|
+
- footer/actions or filter/status component
|
|
89
|
+
- Allow a single-file implementation only for very small throwaway demos; if chosen, explicitly justify why splitting is unnecessary.
|
|
90
|
+
|
|
91
|
+
### Component data flow
|
|
92
|
+
|
|
93
|
+
- Must-read reference from `1.1`: [component-data-flow](references/component-data-flow.md)
|
|
94
|
+
- Use props down, events up as the primary model.
|
|
95
|
+
- Use `v-model` only for true two-way component contracts.
|
|
96
|
+
- Use provide/inject only for deep-tree dependencies or shared context.
|
|
97
|
+
- Keep contracts explicit and typed with `defineProps`, `defineEmits`, and `InjectionKey` as needed.
|
|
98
|
+
|
|
99
|
+
### Composables
|
|
100
|
+
|
|
101
|
+
- Must-read reference from `1.1`: [composables](references/composables.md)
|
|
102
|
+
- Extract logic into composables when it is reused, stateful, or side-effect heavy.
|
|
103
|
+
- Keep composable APIs small, typed, and predictable.
|
|
104
|
+
- Separate feature logic from presentational components.
|
|
105
|
+
|
|
106
|
+
## 3) Consider optional features only when requirements call for them
|
|
107
|
+
|
|
108
|
+
### 3.1 Standard optional features
|
|
109
|
+
|
|
110
|
+
Do not add these by default. Load the matching reference only when the requirement exists.
|
|
111
|
+
|
|
112
|
+
- Slots: parent needs to control child content/layout -> [component-slots](references/component-slots.md)
|
|
113
|
+
- Fallthrough attributes: wrapper/base components must forward attrs/events safely -> [component-fallthrough-attrs](references/component-fallthrough-attrs.md)
|
|
114
|
+
- Built-in component `<KeepAlive>` for stateful view caching -> [component-keep-alive](references/component-keep-alive.md)
|
|
115
|
+
- Built-in component `<Teleport>` for overlays/portals -> [component-teleport](references/component-teleport.md)
|
|
116
|
+
- Built-in component `<Suspense>` for async subtree fallback boundaries -> [component-suspense](references/component-suspense.md)
|
|
117
|
+
- Animation-related features: pick the simplest approach that matches the required motion behavior.
|
|
118
|
+
- Built-in component `<Transition>` for enter/leave effects -> [transition](references/component-transition.md)
|
|
119
|
+
- Built-in component `<TransitionGroup>` for animated list mutations -> [transition-group](references/component-transition-group.md)
|
|
120
|
+
- Class-based animation for non-enter/leave effects -> [animation-class-based-technique](references/animation-class-based-technique.md)
|
|
121
|
+
- State-driven animation for user-input-driven animation -> [animation-state-driven-technique](references/animation-state-driven-technique.md)
|
|
122
|
+
|
|
123
|
+
### 3.2 Less-common optional features
|
|
124
|
+
|
|
125
|
+
Use these only when there is explicit product or technical need.
|
|
126
|
+
|
|
127
|
+
- Directives: behavior is DOM-specific and not a good composable/component fit -> [directives](references/directives.md)
|
|
128
|
+
- Async components: heavy/rarely-used UI should be lazy loaded -> [component-async](references/component-async.md)
|
|
129
|
+
- Render functions only when templates cannot express the requirement -> [render-functions](references/render-functions.md)
|
|
130
|
+
- Plugins when behavior must be installed app-wide -> [plugins](references/plugins.md)
|
|
131
|
+
- State management patterns: app-wide shared state crosses feature boundaries -> [state-management](references/state-management.md)
|
|
132
|
+
|
|
133
|
+
## 4) Run performance optimization after behavior is correct
|
|
134
|
+
|
|
135
|
+
Performance work is a post-functionality pass. Do not optimize before core behavior is implemented and verified.
|
|
136
|
+
|
|
137
|
+
- Large list rendering bottlenecks -> [perf-virtualize-large-lists](references/perf-virtualize-large-lists.md)
|
|
138
|
+
- Static subtrees re-rendering unnecessarily -> [perf-v-once-v-memo-directives](references/perf-v-once-v-memo-directives.md)
|
|
139
|
+
- Over-abstraction in hot list paths -> [perf-avoid-component-abstraction-in-lists](references/perf-avoid-component-abstraction-in-lists.md)
|
|
140
|
+
- Expensive updates triggered too often -> [updated-hook-performance](references/updated-hook-performance.md)
|
|
141
|
+
|
|
142
|
+
## 5) Final self-check before finishing
|
|
143
|
+
|
|
144
|
+
- Core behavior works and matches requirements.
|
|
145
|
+
- All must-read references were read and applied.
|
|
146
|
+
- Reactivity model is minimal and predictable.
|
|
147
|
+
- SFC structure and template rules are followed.
|
|
148
|
+
- Components are focused and well-factored, splitting when needed.
|
|
149
|
+
- Entry/root and route view components remain composition surfaces unless there is an explicit small-demo exception.
|
|
150
|
+
- Component split decisions are explicit and defensible (responsibility boundaries are clear).
|
|
151
|
+
- Data flow contracts are explicit and typed.
|
|
152
|
+
- Composables are used where reuse/complexity justifies them.
|
|
153
|
+
- Moved state/side effects into composables if applicable
|
|
154
|
+
- Optional features are used only when requirements demand them.
|
|
155
|
+
- Performance changes were applied only after functionality was complete.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use Class-based Animations for Non-Enter/Leave Effects
|
|
3
|
+
impact: LOW
|
|
4
|
+
impactDescription: Class-based animations are simpler and more performant for elements that remain in the DOM
|
|
5
|
+
type: best-practice
|
|
6
|
+
tags: [vue3, animation, css, class-binding, state]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Use Class-based Animations for Non-Enter/Leave Effects
|
|
10
|
+
|
|
11
|
+
**Impact: LOW** - For animations on elements that are not entering or leaving the DOM, use CSS class-based animations triggered by Vue's reactive state. This is simpler than `<Transition>` and more appropriate for feedback animations like shake, pulse, or highlight effects.
|
|
12
|
+
|
|
13
|
+
## Task List
|
|
14
|
+
|
|
15
|
+
- Use class-based animations for elements staying in the DOM
|
|
16
|
+
- Use `<Transition>` only for enter/leave animations
|
|
17
|
+
- Combine CSS animations with Vue's class bindings (`:class`)
|
|
18
|
+
- Consider using `setTimeout` to auto-remove animation classes
|
|
19
|
+
|
|
20
|
+
**When to Use Class-based Animations:**
|
|
21
|
+
|
|
22
|
+
- User feedback (shake on error, pulse on success)
|
|
23
|
+
- Attention-grabbing effects (highlight changes)
|
|
24
|
+
- Hover/focus states that need more than CSS transitions
|
|
25
|
+
- Any animation where the element stays mounted
|
|
26
|
+
|
|
27
|
+
**When to Use Transition Component:**
|
|
28
|
+
|
|
29
|
+
- Elements entering/leaving the DOM (v-if/v-show)
|
|
30
|
+
- Route transitions
|
|
31
|
+
- List item additions/removals
|
|
32
|
+
|
|
33
|
+
## Basic Pattern
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<script setup>
|
|
37
|
+
import { ref } from 'vue'
|
|
38
|
+
|
|
39
|
+
const showError = ref(false)
|
|
40
|
+
|
|
41
|
+
function submitForm() {
|
|
42
|
+
if (!isValid()) {
|
|
43
|
+
// Trigger shake animation
|
|
44
|
+
showError.value = true
|
|
45
|
+
|
|
46
|
+
// Auto-remove class after animation completes
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
showError.value = false
|
|
49
|
+
}, 820) // Match animation duration
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<div :class="{ shake: showError }">
|
|
56
|
+
<button @click="submitForm">Submit</button>
|
|
57
|
+
<span v-if="showError">This feature is disabled!</span>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
.shake {
|
|
63
|
+
animation: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
|
|
64
|
+
transform: translate3d(0, 0, 0); /* Enable GPU acceleration */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@keyframes shake {
|
|
68
|
+
10%,
|
|
69
|
+
90% {
|
|
70
|
+
transform: translate3d(-1px, 0, 0);
|
|
71
|
+
}
|
|
72
|
+
20%,
|
|
73
|
+
80% {
|
|
74
|
+
transform: translate3d(2px, 0, 0);
|
|
75
|
+
}
|
|
76
|
+
30%,
|
|
77
|
+
50%,
|
|
78
|
+
70% {
|
|
79
|
+
transform: translate3d(-4px, 0, 0);
|
|
80
|
+
}
|
|
81
|
+
40%,
|
|
82
|
+
60% {
|
|
83
|
+
transform: translate3d(4px, 0, 0);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Common Animation Patterns
|
|
90
|
+
|
|
91
|
+
### Pulse on Success
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<script setup>
|
|
95
|
+
import { ref } from 'vue'
|
|
96
|
+
|
|
97
|
+
const saved = ref(false)
|
|
98
|
+
|
|
99
|
+
async function save() {
|
|
100
|
+
await saveData()
|
|
101
|
+
saved.value = true
|
|
102
|
+
setTimeout(() => (saved.value = false), 1000)
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<template>
|
|
107
|
+
<button :class="{ pulse: saved }" @click="save">
|
|
108
|
+
{{ saved ? 'Saved!' : 'Save' }}
|
|
109
|
+
</button>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<style>
|
|
113
|
+
.pulse {
|
|
114
|
+
animation: pulse 0.5s ease-in-out;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@keyframes pulse {
|
|
118
|
+
0%,
|
|
119
|
+
100% {
|
|
120
|
+
transform: scale(1);
|
|
121
|
+
}
|
|
122
|
+
50% {
|
|
123
|
+
transform: scale(1.05);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Highlight on Change
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<script setup>
|
|
133
|
+
import { ref, watch } from 'vue'
|
|
134
|
+
|
|
135
|
+
const value = ref(0)
|
|
136
|
+
const justUpdated = ref(false)
|
|
137
|
+
|
|
138
|
+
watch(value, () => {
|
|
139
|
+
justUpdated.value = true
|
|
140
|
+
setTimeout(() => (justUpdated.value = false), 1000)
|
|
141
|
+
})
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<template>
|
|
145
|
+
<div :class="{ highlight: justUpdated }">Value: {{ value }}</div>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<style>
|
|
149
|
+
.highlight {
|
|
150
|
+
animation: highlight 1s ease-out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@keyframes highlight {
|
|
154
|
+
0% {
|
|
155
|
+
background-color: yellow;
|
|
156
|
+
}
|
|
157
|
+
100% {
|
|
158
|
+
background-color: transparent;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
</style>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Bounce Attention
|
|
165
|
+
|
|
166
|
+
```vue
|
|
167
|
+
<script setup>
|
|
168
|
+
import { ref } from 'vue'
|
|
169
|
+
|
|
170
|
+
const needsAttention = ref(false)
|
|
171
|
+
|
|
172
|
+
function notifyUser() {
|
|
173
|
+
needsAttention.value = true
|
|
174
|
+
// No setTimeout needed - using animationend event
|
|
175
|
+
}
|
|
176
|
+
</script>
|
|
177
|
+
|
|
178
|
+
<template>
|
|
179
|
+
<div :class="{ bounce: needsAttention }" @animationend="needsAttention = false">
|
|
180
|
+
<BellIcon />
|
|
181
|
+
</div>
|
|
182
|
+
</template>
|
|
183
|
+
|
|
184
|
+
<style>
|
|
185
|
+
.bounce {
|
|
186
|
+
animation: bounce 0.5s ease;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@keyframes bounce {
|
|
190
|
+
0%,
|
|
191
|
+
100% {
|
|
192
|
+
transform: translateY(0);
|
|
193
|
+
}
|
|
194
|
+
50% {
|
|
195
|
+
transform: translateY(-10px);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
</style>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Using animationend Event
|
|
202
|
+
|
|
203
|
+
Instead of `setTimeout`, use the `animationend` event for cleaner code:
|
|
204
|
+
|
|
205
|
+
```vue
|
|
206
|
+
<script setup>
|
|
207
|
+
import { ref } from 'vue'
|
|
208
|
+
|
|
209
|
+
const isAnimating = ref(false)
|
|
210
|
+
|
|
211
|
+
function triggerAnimation() {
|
|
212
|
+
isAnimating.value = true
|
|
213
|
+
// Class is automatically removed when animation ends
|
|
214
|
+
}
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<template>
|
|
218
|
+
<div :class="{ animate: isAnimating }" @animationend="isAnimating = false">Content</div>
|
|
219
|
+
</template>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Composable for Reusable Animations
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
// composables/useAnimation.js
|
|
226
|
+
import { ref } from 'vue'
|
|
227
|
+
|
|
228
|
+
export function useAnimation(duration = 500) {
|
|
229
|
+
const isAnimating = ref(false)
|
|
230
|
+
|
|
231
|
+
function trigger() {
|
|
232
|
+
isAnimating.value = true
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
isAnimating.value = false
|
|
235
|
+
}, duration)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
isAnimating,
|
|
240
|
+
trigger,
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```vue
|
|
246
|
+
<script setup>
|
|
247
|
+
import { useAnimation } from '@/composables/useAnimation'
|
|
248
|
+
|
|
249
|
+
const shake = useAnimation(820)
|
|
250
|
+
const pulse = useAnimation(500)
|
|
251
|
+
</script>
|
|
252
|
+
|
|
253
|
+
<template>
|
|
254
|
+
<button :class="{ shake: shake.isAnimating.value }" @click="shake.trigger()">Shake me</button>
|
|
255
|
+
|
|
256
|
+
<button :class="{ pulse: pulse.isAnimating.value }" @click="pulse.trigger()">Pulse me</button>
|
|
257
|
+
</template>
|
|
258
|
+
```
|