xiaohongshu
xiaohongshu
beaver-build
Build robust test dams that catch bugs before they flood production. The beaver surveys the stream, gathers materials wisely, builds with care, reinforces thoroughly, and ships with confidence. Use when writing tests, deciding what to test, or reinforcing code.
Full skill instructions
The beaver doesn't build blindly. First, it surveys the stream, understanding the flow. Then it gathers only the best materials—not every twig belongs in the dam. It builds with purpose, each piece placed carefully. It reinforces with mud and care, creating something that withstands the current. When the dam holds, the forest is safe.
/beaver-build or mentions beaver/building damsPair with: javascript-testing for Vitest syntax, python-testing for pytest patterns
SURVEY → GATHER → BUILD → REINFORCE → FORTIFY
↓ ↲ ↓ ↲ ↓
Understand Collect Construct Harden Ship with
Flow Materials Tests Coverage Confidence
The beaver surveys the stream, understanding the flow before placing a single twig...
Before gathering materials, understand what you're building for:
What does this feature DO for users? (Not how it works—what value it provides)
What would break if this failed? (Critical paths)
What's the confidence level needed? (Prototype vs. production)
The Testing Trophy (where confidence lives):
╭─────────╮
│ E2E │ ← Few: critical user journeys
╰────┬────╯
╭─────────┴─────────╮
│ Integration │ ← Many: this is where confidence lives
╰─────────┬─────────╯
╭──────┴──────╮
│ Unit │ ← Some: pure functions, algorithms
╰──────┬──────╯
╭──────────┴──────────╮
│ Static Analysis │ ← TypeScript, ESLint (always on)
╰─────────────────────╯
What Each Layer Does:
Static Analysis (TypeScript, ESLint)
Unit Tests
Integration Tests (THE SWEET SPOT)
E2E Tests (Playwright)
Output: Brief summary of what needs testing and at what layer
Paws select only the best branches. Not everything belongs in the dam...
Decide what to test using the Confidence Test:
Skip Testing:
| What | Why |
|---|---|
| Trivial code | Getters, setters, data models with no logic |
| Framework behavior | Trust that SvelteKit routing works |
| Implementation details | Internal state, private methods, CSS classes |
| One-off scripts | Maintenance cost exceeds value |
| Volatile prototypes | Requirements unclear, code will change |
Test Lightly:
| What | Approach |
|---|---|
| Configuration | Smoke test that it loads, not every option |
| Third-party integrations | Mock at boundaries, test your code's response |
| Visual design | Snapshot tests or visual regression, not unit tests |
Test Thoroughly:
| What | Why |
|---|---|
| Business logic | Core value of the application |
| User-facing flows | What users actually experience |
| Edge cases | Error states, empty states, boundaries |
| Bug fixes | Every bug becomes a test to prevent regression |
The Guiding Principle:
"The more your tests resemble the way your software is used, the more confidence they can give you." — Kent C. Dodds (Testing Library)
Ask: Would I notice if this broke in production? If yes, test it.
Ask: Does this test fail when the feature breaks? If no, don't write it.
Ask: Does this test resemble how users interact with the feature? If no, reconsider.
What Makes a Test Valuable (Kent Beck's Test Desiderata):
| Property | What It Means |
|---|---|
| Behavior-sensitive | Fails when actual functionality breaks |
| Structure-immune | Doesn't break when you refactor safely |
| Deterministic | Same result every time, no flakiness |
| Fast | Gives feedback in seconds, not minutes |
| Clear diagnosis | When it fails, you know exactly what broke |
| Cheap to write | Effort proportional to code complexity |
Output: List of test cases to write, organized by layer (unit/integration/E2E)
Twig by twig, the dam takes shape. Each piece has purpose...
Write tests following Arrange-Act-Assert:
it('should reject invalid email during registration', async () => {
// Arrange: Set up the scenario
const invalidEmail = 'not-an-email';
// Act: Do the thing (ONE line)
const result = await registerUser({ email: invalidEmail, password: 'valid123' });
// Assert: Check the outcome
expect(result.success).toBe(false);
expect(result.error).toContain('email');
});
The Act section should be one line. If it's not, the test is probably doing too much.
Test User Behavior, Not Implementation:
// Bad: Testing implementation
it('should set isLoading state to true', async () => {
const { component } = render(LoginForm);
await fireEvent.click(getByRole('button'));
expect(component.isLoading).toBe(true); // Testing internal state!
});
// Good: Testing user experience
it('should show loading indicator while logging in', async () => {
render(LoginForm);
await fireEvent.click(getByRole('button', { name: /sign in/i }));
expect(getByRole('progressbar')).toBeInTheDocument();
});
Use Accessible Queries (how users find elements):
// Priority order (best to worst):
getByRole('button', { name: /submit/i }) // How screen readers see it
getByLabelText('Email') // Form fields
getByText('Welcome back') // Visible text
getByTestId('login-form') // Last resort
Test Names That Explain:
Good names:
should reject registration with invalid emailshould show error message when API failsshould preserve draft when navigating awayBad names:
test email validation (what about it?)handleSubmit works (what does "works" mean?)test case 1 (no)Test One Thing:
Each test should have one reason to fail. If a test fails, you should immediately know what broke.
// Bad: Testing multiple things
it('should handle registration', async () => {
// Tests validation, API call, redirect, AND email sending
});
// Good: Focused tests
it('should reject invalid email format', ...);
it('should call API with valid data', ...);
it('should redirect after successful registration', ...);
it('should send welcome email after registration', ...);
Integration Test Pattern (where most tests should live):
// Multiple units working together
it('should complete checkout flow', async () => {
// Arrange
const cart = await createCart({ items: [item1, item2] });
// Act
const order = await checkout(cart.id, paymentMethod);
// Assert
expect(order.status).toBe('confirmed');
expect(order.total).toBe(cart.total);
expect(await getInventory(item1.id)).toBe(item1.stock - 1);
});
Output: Working tests that follow AAA pattern and test behavior, not implementation
The beaver packs mud between twigs, hardening the structure...
Strengthen tests with:
Minimal Mocking:
// Over-mocked: False confidence
vi.mock('./api');
vi.mock('./validation');
vi.mock('./utils');
// You're testing... nothing real
// Better: Mock at boundaries only
vi.mock('./external-api'); // Mock the network, not your code
// Let validation, utils, etc. run for real
Rule of thumb: If you're mocking something you wrote, reconsider.
Bug → Test Pipeline:
Every production bug should become a test:
This is one of the highest-value testing practices. It turns pain into protection.
Test Location:
Keep tests close to code:
src/
└── lib/
└── features/
└── auth/
├── login.ts
├── login.test.ts ← Right next to the code
└── register.ts
Output: Hardened tests with proper mocking boundaries and clear failure messages
The dam holds. Water flows as intended. The beaver rests...
Final checks:
# Run tests
npx vitest run
# Check coverage (signal, not goal)
npx vitest run --coverage
# Run with other quality checks
npm run lint && npm run typecheck && npx vitest run
Self-Review Checklist:
Before considering tests "done":
When Tests Break:
Tests that break are telling you something. Listen.
Good Breaks (Expected):
Bad Breaks (Symptoms of Poor Tests):
If refactoring frequently breaks tests, your tests are testing the wrong things.
Output: Clean test suite ready for CI
Build with purpose. The beaver doesn't add twigs just to add them. Each test must earn its place by providing confidence.
Test behavior, not structure. If refactoring breaks your tests, they were testing the wrong things.
Remember the trophy: Mostly integration, some unit, few E2E. Static analysis is your first line of defense.
Good tests let you ship with confidence. That's the whole point.
Use building metaphors:
The beaver does NOT:
The Ice Cream Cone (AVOID):
╭───────────────────────────╮
│ Many E2E tests │ ← Slow, brittle, expensive
╰───────────┬───────────────╯
╭─────┴─────╮
│ Few int. │
╰─────┬─────╯
╭───┴───╮
│ Few │
│ unit │
╰───────╯
This is backwards. E2E tests are expensive. Integration tests give the best ROI.
User: "Add tests for the login form"
Beaver flow:
🦫 SURVEY — "Login form handles user authentication. Critical path: registration → dashboard flow. Integration tests where confidence lives."
🦫 GATHER — "Test: invalid email rejection, API error handling, successful redirect, loading states. Skip: internal state changes."
🦫 BUILD — Write integration tests using AAA pattern:
should reject registration with invalid emailshould show loading indicator while logging inshould redirect to dashboard after successful login🦫 REINFORCE — Add regression test for previous password reset bug. Mock only external API, not internal validation.
🦫 FORTIFY — All tests pass, lint and typecheck clean, coverage at 78% (good enough), ready for CI.
| Situation | Action |
|---|---|
| New feature | Write integration tests for user-facing behavior |
| Bug fix | Write test that reproduces bug first, then fix |
| Refactoring | Run existing tests; if they break on safe changes, they're bad tests |
| "Need more coverage" | Add tests for uncovered behavior, not uncovered lines |
| Pure function/algorithm | Unit test it |
| API endpoint | Integration test with mocked external services |
| UI component | Component test with Testing Library |
| Critical user flow | E2E test with Playwright |
Good tests let you ship with confidence. That's the whole point. 🦫
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience