Index of every page on this site: llms.txt
All skills
xai-org avatar

/fix-a-bug

@002788b
by SpaceXSI Orgxai-org/xai-cookbook655 stars
211
Run it yourself

How to reproduce and fix a bug in tiny-checkout, a store's cart, coupon, shipping, and total logic. Covers running the tests with node --test, where the code and tests live, and the steps and conventions every fix follows.

  • 1 file
  • 2 KB
  • Updated 2 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/xai-org/xai-cookbook/fix-a-bug

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈58 tokens for metadata: the name and description. ≈450 when used: this file.

Description uses 2.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈234 characters, or 2.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Fixing a bug in tiny-checkout

tiny-checkout is the checkout logic of a small web store. It's plain JavaScript in ES modules with no dependencies, so there's nothing to install.

Where things are

  • src/money.js turns prices in dollars into whole cents and formats cents for display.
  • src/cart.js keeps the cart's lines and adds up the subtotal.
  • src/coupons.js looks up coupon codes and works out their discount.
  • src/checkout.js puts it together: subtotal, shipping, discount, and total.
  • test/<name>.test.js has the tests for src/<name>.js.

Running the tests

  • Every test: node --test
  • One file: node --test test/money.test.js

The output lists each test with ✔ or ✖, then a summary. A failing test shows the expected and actual values.

Steps

  1. Run node --test to see where things stand before you change anything.
  2. Find the code behind the symptom. Start from what the report describes, read the files involved, and follow the calls with grep -rn.
  3. Add a test that reproduces the report to the test file of the module you'll fix, and run it to watch it fail. A fix without a failing test first isn't done.
  4. Fix the cause, not the symptom, with the smallest change that works.
  5. Run node --test again, and keep going until every test passes.
  6. Finish with two or three sentences on what was wrong and what you changed.

Conventions

  • Amounts are whole cents everywhere. Dollars become cents once, in toCents(), when a product goes into the cart.
  • Tests use node:test and node:assert/strict, with one test() per behavior, named after the behavior in plain words, like the existing ones.
  • Keep the style of the file you're editing: two-space indents, double quotes, semicolons.
  • Don't add dependencies or change package.json.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 002788b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 months ago

README badge

README badge for xai-org/xai-cookbook/fix-a-bug