- Home
- Skills
- Frontend & Web Apps
- User Story To Code
Works with the AI Agents you already use
User Story To Code
Hand it a user story and get code that fits your project: conventions read from your files first, a plan, full files, and every acceptance criterion mapped to a code path
$5
/moSubscription · cancel anytime
Secure checkout via Stripe
- Always the latest version
- Delivered live to your agent via MCP
- Cancel anytime, access ends at period end
User Story To Code
Example session with this skill installed
As a shopper I want to sort the product list by price (low to high, high to low) so I can find something in my budget. Acceptance criteria: a sort select above the list; default order unchanged until I pick; sorting never mutates the products prop. Plan approved in advance, go straight to code. The project (Vite + React + TS):
src/types.ts
export interface Product { id: string; name: string; priceCents: number; }
src/components/ProductList.tsx
import { Product } from '../types';
import { ProductCard } from './ProductCard';
export function ProductList({ products }: { products: Product[] }) {
return (
<ul className="grid gap-4">
{products.map((p) => (<li key={p.id}><ProductCard product={p} /></li>))}
</ul>
);
}
src/hooks/useCart.ts exists and exports useCart(); components are named exports, one per file.
- Read your context and instructions
- Compiled the user story to
- Generated the UI component
Story
- Role: shopper
- Goal: sort the product list by price, low to high or high to low
- Reason: find something within budget
- Acceptance criteria:
- A sort select sits above the list.
- The default order stays unchanged until a sort is picked.
- Sorting never mutates the
productsprop.
All three are clear enough to build. I made two small assumptions and list them under the integration notes.
Conventions I followed (taken from the files you pasted)
- Named exports with
export function, one component per file, PascalCase file names insrc/components/. - Hooks live in
src/hooks/asuseXxx.tsnamed exports, the same pattern asuseCart.ts. - Shared types live in
src/types.ts. - Relative imports, single quotes, semicolons, inline prop types (
{ products }: { products: Product[] }), Tailwind utility classes.
I only had the pasted files to go on, not the whole repo. I didn't see any existing sort helper, so nothing here duplicates one. If one exists somewhere else, use it inside the hook instead.
Plan (you approved it up front, so here it is for reference)
| File | Change | Responsibility |
|---|---|---|
src/types.ts | modify | add a PriceSort union so the hook and the component share one set of values |
src/hooks/useSortedProducts.ts | create | sorts a copy of the array, memoised, and returns the original array untouched for 'default' |
src/components/ProductList.tsx | modify | owns the sort state, renders the labelled select above the list, and maps the sorted result |
Code
src/types.ts
export interface Product { id: string; name: string; priceCents: number; }
export type PriceSort = 'default' | 'price-asc' | 'price-desc';
src/hooks/useSortedProducts.ts (new)
import { useMemo } from 'react';
import { PriceSort, Product } from '../types';
export function useSortedProducts(products: Product[], sort: PriceSort): Product[] {
return useMemo(() => {
if (sort === 'default') return products;
// Copy before sorting: Array.prototype.sort works in place and would mutate the prop.
// sort() is stable, so items with the same price keep their original relative order.
const direction = sort === 'price-asc' ? 1 : -1;
return [...products].sort((a, b) => (a.priceCents - b.priceCents) * direction);
}, [products, sort]);
}
src/components/ProductList.tsx
import { useState } from 'react';
import { PriceSort, Product } from '../types';
import { ProductCard } from './ProductCard';
import { useSortedProducts } from '../hooks/useSortedProducts';
export function ProductList({ products }: { products: Product[] }) {
const [sort, setSort] = useState<PriceSort>('default');
const sortedProducts = useSortedProducts(products, sort);
return (
<div className="grid gap-4">
<label className="flex items-center gap-2 justify-self-start">
<span>Sort by</span>
<select
value={sort}
onChange={(e) => setSort(e.target.value as PriceSort)}
className="rounded border px-2 py-1"
>
<option value="default">Featured</option>
<option value="price-asc">Price: low to high</option>
<option value="price-desc">Price: high to low</option>
</select>
</label>
<ul className="grid gap-4">
{sortedProducts.map((p) => (<li key={p.id}><ProductCard product={p} /></li>))}
</ul>
</div>
);
}
How each criterion maps to the code
| Criterion | Where it happens |
|---|---|
| Sort select above the list | ProductList.tsx: the <label>/<select> comes before the <ul> inside the wrapper |
| Default order unchanged until picked | useState<PriceSort>('default'), and the hook returns products itself (same reference, same order) when sort === 'default' |
Never mutates the products prop | useSortedProducts.ts: [...products].sort(...) sorts a shallow copy, and nothing ever calls sort on the prop itself |
Wiring
- No barrel or route changes.
ProductListkeeps its name, its export and its props, so every existing caller works as it is. - The new hook is imported directly by path, the same way
ProductCardis. If you have asrc/hooks/index.tsbarrel I haven't seen, addexport { useSortedProducts } from './useSortedProducts';to it.
Integration notes (manual checks on your side)
The root element changed. ProductList used to render a <ul> at the root, and now it renders a <div> wrapping the select and the <ul>. If a parent component or a CSS rule targets ProductList's root as a ul (for example > ul or ul.grid), check that layout.
2.
Option label for the default order. I called it "Featured" because that is the usual shop wording for "the order the list arrived in". Rename it if your UI uses a different word, but keep the value 'default'.
3.
Ties. Products with the same price keep their original relative order, because Array.prototype.sort is stable in every engine Vite targets.
4.
Sort resets on remount. The choice lives in local component state, so it is lost on navigation. The story doesn't ask for it to persist (URL or storage), so I left that out.
5.
TypeScript lib. I used [...products].sort() rather than toSorted(), so this compiles whatever lib/target your tsconfig sets.
Nothing touches useCart. Tests aren't included. If you want one, the useful assertion is that products is still in its original order after you switch the select to each option.
ProductList.tsx
TSX · React component
Example file from a real run - the skill writes it into your workspace.
Subscription · always the latest version
- Secure checkout via Stripe
- Cancel anytime
- Delivered live via MCP
About this skill
Paste a user story, a ticket or a list of acceptance criteria, and it writes the code the way your project already writes code. Before writing anything it reads the folder layout and two or three representative files, and copies their naming, export style and import patterns. It looks for helpers that already do the job, so it doesn't add a duplicate. Then it lays out a plan, file by file, and writes each file in full.
What it does
You get the story broken into role, goal, reason and criteria, the conventions it found, a plan table (file, create or modify, responsibility), the code for every file labelled with its path, a table mapping each acceptance criterion to the exact place in the code that satisfies it, the wiring changes (imports, barrels, routes), and integration notes for anything it could not do for you. By default it stops after the plan for your approval. Say "plan approved, go straight to code" to skip that.
Try it first
Open a repo and paste a story like "As a shopper I want to sort the product list by price so I can stay in budget", with its acceptance criteria. The code that comes back should look like it was written by whoever wrote the file next to it.
What it needs
Read access to the repo, so it can learn its conventions, and write access if you want it to apply the files. If the code isn't on disk, paste the relevant files into the message, as in the demo. Works with any stack; the examples are React and TypeScript.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Frontend & Web Apps.
It doesn't write tests, database migrations, CI configuration or infrastructure, and it won't refactor existing code unless a story asks for it. It learns conventions from the files it reads, so in a repo with mixed styles it follows the layer the story touches, and a convention in a file it never opened can be missed. When you only paste a few files, it says which assumptions it made instead of guessing silently. Vague acceptance criteria are flagged for clarification before it writes code.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 28 days ago