Vibe coding with Claude Code course · Module 7: LinkedIn clone
The seaman's book: a professional profile and your first custom skill
In this lesson12
Ahoy! In harbor taverns, captains look for navigators and navigators look for good ships, but nobody knows who can do what. In this location you build Crew Connections, a professional network for pirates in the style of LinkedIn. In Kraken's Call, the Twitter clone, loose posts and likes were what counted; here it is positions, time in a job and skills confirmed by the crew. A profile works like a seaman's book: it shows where you have sailed and what you can do.
What you will learn
- ask Claude Code for a profile with experience and skill endorsements;
- read a form built with a Server Action, server-side validation and errors under the fields;
- check that the server guards the rules, not just the button;
- save a repeatable procedure as your own Claude Code skill and read its file.
A new port: the crew-connections project
A professional network is a separate app, so you create it with the command from lesson 1_2, changing only the name. Before you click Yes, compare the command with this one:
npx create-next-app@latest crew-connections --ts --eslint --tailwind --app --no-src-dir --no-cache-components --agents-md --no-agent-feedback --use-npmThe rest is the familiar routine: a session in the crew-connections folder, a CLAUDE.md that imports @AGENTS.md, Vitest with the same @types/node fix as in lesson 4_1, and a first commit.
The problem: three similar forms
A pirate wants to fix their professional headline, a captain wants to post a job offer, and a candidate wants to send an application. These are three forms with the same risk: the browser checks only what you tell it to, and anyone can send anything to the server. That is why the server guards the rules. You build the first form properly, and then you save the recipe so that Claude can repeat it with one command.
Request for Claude Code:
/plan Build a professional profile in Crew Connections. Page /in/[handle]:
a header (name, headline, port, number of connections), experience with
time in a job calculated from dates (no endDate = the job is ongoing)
and skills with endorsements. You can endorse only someone else's skill
and only once; the server enforces this. Page /profile/edit with a form:
saved through a Server Action, server-side validation following the Forms
guide in node_modules/next/dist/docs, errors under the fields, typed
values stay after an error. There is no login yet: the signed-in pirate
comes from one function in lib/session.ts. Data in data/*.json. Date
formatting in lib/format.ts, tests first. At the end run tests, lint,
types and build.In the plan you look for three things: validation in a file with "use server", the pirate taken from lib/session.ts instead of a form field, and tests before the formatting code. Claude proposed the Zod library, which the Forms guide recommends for server-side validation. It is a single package, so you agree.
What Claude wrote: the profile in types
Open types/profile.ts in Cursor. The Profile type has a handle (the short name in the address, like redbeard), a name, a headline, which is a professional title such as "Captain and navigator on the Black Pearl", a port, an "About me" text, a number of connections, and lists of experience and skills. There are no tweets or likes fields, that is another world. Below it stand two smaller types:
export interface Experience {
id: string;
title: string;
company: string;
startDate: string; // "2023-03": year and month as an ISO string
endDate?: string; // missing = the job is ongoing
description?: string;
}
export interface Skill {
id: string;
name: string;
endorsedBy: string[]; // handles of people who endorsed the skill
}A missing endDate means a position that is still going on. An endorsement is a single click with which you vouch that someone really knows navigation, so endorsedBy holds who has already vouched. A recommendation is something else: a written reference about the whole collaboration, which you will add later.
Time in a job calculated from dates
Open lib/format.ts. Claude wrote the tests first, then the function:
export function formatDuration(start: string, end?: string, today = new Date()): string {
const until = end ?? `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}`;
const months = monthsBetween(start, until);
if (months < 1) return "less than a month";
const years = Math.floor(months / 12);
const rest = months % 12;
const parts: string[] = [];
if (years > 0) parts.push(formatYears(years));
if (rest > 0) parts.push(`${rest} mo.`);
return parts.join(" ");
}monthsBetween counts the months between two dates, and then the function splits them into years and a remainder: from March 2023 to August 2025 is 29 months, so "2 years 5 mo.". Without an end date it counts up to today, and the parameter lets the tests pass a fixed date. formatYears from the same file picks the form with the built-in Intl.PluralRules("en-US"): 1 year, 2 years. A bare ${years} years would print "1 years", which is why the plural form is chosen by a rule and not pasted in. In ExperienceSection the date line looks like this: formatMonth(job.startDate) - present · formatDuration(...), for example "Mar 2023 - present".
Endorsements: the server decides
A Server Action is a function with the "use server" directive that runs on the server, and the browser calls it by submitting a form. Open components/profile/SkillsSection.tsx (classes omitted):
{!isOwn && (
<form action={endorseSkill.bind(null, profile.handle, skill.id)}>
<button disabled={endorsed}>{endorsed ? "Endorsed" : "+ Endorse"}</button>
</form>
)}bind attaches the profile handle and the skill id to the action; that is how the documentation passes extra arguments. On your own profile there are no buttons, and a disabled button is only a hint. The Server Actions documentation warns that a request can be sent bypassing the interface, so endorseSkill in app/in/[handle]/actions.ts checks everything again: it asks getCurrentUser(), rejects your own profile and a second endorsement, appends the handle to endorsedBy, saves, and calls revalidatePath so the page shows the new count.
The form: rules in a schema
Open lib/validation/profile.ts. A Zod schema is a description of valid data:
export const profileSchema = z.object({
name: z.string().trim().min(2, "Enter your name (at least 2 characters).").max(60, "At most 60 characters."),
headline: z.string().trim().min(5, "Describe yourself in a few words (at least 5 characters).").max(120, "At most 120 characters."),
location: z.string().trim().max(60, "At most 60 characters."),
about: z.string().trim().max(1000, "At most 1000 characters."),
});trim() cuts the spaces before min runs, so a name made of spaces does not pass. The schema saves nothing and throws no exceptions: its safeParse returns either cleaned data or a list of errors.
The form: the action on the server
Open app/profile/edit/actions.ts:
export async function updateProfile(
_prevState: FormState<ProfileInput>,
formData: FormData,
): Promise<FormState<ProfileInput>> {
const user = await getCurrentUser();
const values = {
name: String(formData.get("name") ?? ""),
headline: String(formData.get("headline") ?? ""),
location: String(formData.get("location") ?? ""),
about: String(formData.get("about") ?? ""),
};
const result = profileSchema.safeParse(values);
if (!result.success) {
return { values, errors: z.flattenError(result.error).fieldErrors };
}
const profile = await getProfile(user.handle);
if (!profile) {
return { values, errors: {}, message: "Your profile was not found." };
}
await saveProfile({ ...profile, ...result.data });
revalidatePath(`/in/${user.handle}`);
redirect(`/in/${user.handle}`);
}The action reads only the four expected fields from FormData, and whose profile it is comes from the session, not from the form. On an error it returns the typed values and errors such as { name: ["Enter your name (at least 2 characters)."] }, saving nothing. On success saveProfile writes the profile through lib/store.ts to the file data/profiles.json (Claude added the data folder to .gitignore), revalidatePath refreshes the profile page, and redirect takes you there; code after redirect never runs.
The form: errors under the fields
Open components/profile/ProfileForm.tsx. It is a Client Component with the React hook useActionState, which remembers the last result of the action (button classes omitted):
const [state, formAction, pending] = useActionState(updateProfile, { values: initial, errors: {} });
return (
<form action={formAction} className="space-y-4">
<Field label="Full name" name="name" defaultValue={state.values.name} errors={state.errors.name} maxLength={60} />
{/* headline, port and "About me" the same way */}
<button type="submit" disabled={pending}>{pending ? "Saving..." : "Save profile"}</button>
</form>
);state is the last result, formAction goes to the form, and pending disables the button while the request is in flight. Field draws the label, the input and an error tied to the input through aria-describedby, so a screen reader reads it together with the field.
Captain's review
- Spaces instead of a name. Run
npm run dev, type three spaces in the name and change the headline. The browser lets it through, the server answers "Enter your name (at least 2 characters).", and the new headline stays in the field. A typical agent mistake isdefaultValue={initial.name}: after an action React resets the form to its default values, so in our run the new headline vanished after the error, and under the field with the old name hung a message saying the name was missing. - A docs example from another version. The first schema had
invalid_type_errorand.flatten(), copied from the Forms guide, andnpx tsc --noEmitreported thatinvalid_type_errordoes not exist. npm installed Zod 4 (as of November 2026: 4.6.7), where that option is gone and.flatten()is deprecated. The guide and the package can speak about different versions; the compiler decides. - The edit page after a build. Run
npm run buildandnpm start, save a new headline and return to/profile/edit. In our run the form showed the old one, because the build marked the page with ○, meaning static, and rendered it once. The fix:getCurrentUser()callsawait connection()fromnext/server, like a real session that reads the request. After a new build the page shows ƒ.
A skill: the recipe on parchment
A skill is a file with instructions that Claude Code loads into the conversation only when they are needed: when you type its command, or when Claude decides it fits the task. A project skill lives in .claude/skills/<name>/SKILL.md and becomes the command /name. CLAUDE.md is the ship's law read in every session, and a skill is a recipe taken out of the chest when needed.
Request for Claude Code:
Save how we built the profile form (validation, saving on the
server, error messages) as a skill /new-form in .claude/skills/.
Only I can run it. I will pass the form name as an argument. The
skill should first ask me about the fields, and at the end run
tests, lint, types and build.Open .claude/skills/new-form/SKILL.md. At the top stands the frontmatter, the settings between the --- lines:
---
name: new-form
description: Builds a Crew Connections form following the profile form pattern (Server Action, Zod validation on the server, errors next to the fields).
argument-hint: "[what the form saves, e.g. job offer]"
disable-model-invocation: true
---name gives the command /new-form, and argument-hint gives a hint while typing. disable-model-invocation: true fulfils your "only I": Claude will not run the skill on its own, and according to the documentation even its description is not in context until you type the command. Below it comes the body:
# New form: $ARGUMENTS
Build a form that saves: $ARGUMENTS. The pattern is the profile form:
- lib/validation/profile.ts and lib/validation/profile.test.ts (schema and tests),
- app/profile/edit/actions.ts (Server Action),
- components/profile/ProfileForm.tsx and components/ui/Field.tsx (form).
## Before you write code
1. List the fields: name, type, required or not, limits, allowed values.
2. Write who can submit the form and what it concerns (whose profile, which offer).
3. Ask me whether the list is right. Do not start without an answer.
## Steps
1. Schema tests in lib/validation/<name>.test.ts: valid data, a required field made of spaces, text that is too long, a value outside the list. Tests first, then the schema.
2. A Zod 4 schema in lib/validation/<name>.ts: messages in English, .trim() on text fields, closed lists as an `as const` array and z.enum. No invalid_type_error and no .flatten() (that is the Zod 3 API).
3. A Server Action in actions.ts next to the page, with "use server" at the top of the file:
- the signed-in pirate only from getCurrentUser() in lib/session.ts, never from form fields;
- read only the expected fields from FormData;
- on an error return { values, errors } with z.flattenError(...).fieldErrors and save nothing;
- the author, status and dates are set by the server;
- save through lib/store.ts, then revalidatePath and redirect.
4. The form as a Client Component with useActionState: every field through Field, defaultValue from state.values (React clears fields after an action), the button disabled when pending.
## Check
- npm run test -- --run, npm run lint, npx tsc --noEmit, npm run build.
- In the build output the page with the form is marked ƒ, not ○.
- Show me the results and the list of changed files. Do not add new libraries without asking.Claude Code replaces $ARGUMENTS with whatever you type after the command. Notice that the three findings from the review went into the skill as rules: values from state.values, Zod 4 and the ƒ mark. The .claude/skills folder did not exist when you started the session, and the documentation says such a directory has to be loaded once with the /reload-skills command. After that /skills shows the skill on the list.
Next step
When the review passes, ask for a commit, for example "Professional profile, edit form and the new-form skill". The skill travels in the commit together with the code, so everyone who clones the project gets it. Then a small step with a test:
Extract a pure function canEndorse from endorseSkill into lib/endorse.ts.
Tests first: your own skill, a second endorsement, an unknown
skill. Show me the failure, then the code. Do not change the tests.In the editor below waits a profile in miniature: time in a job calculated from dates, endorsements, and a form whose "server" checks the same rules as the schema. Switch to your profile, type only spaces in the name and see what stays in the fields.
Remember: a seaman's book is signed by the harbor master, not by the sailor, and in the same way the rules of a form are signed by the server.
Code for this lesson: App.jsx
// A seaman's book in miniature: time in a job from dates, endorsements and a form with a "server".
// In the project a Server Action with a Zod schema checks the rules; here the same rules
// are checked by serverUpdateProfile, which answers with a delay like a real server.
import { useState } from 'react';
const TODAY = '2026-11';
const VIEWER = 'redbeard';
const yearWords = { one: 'year', other: 'years' };
const plural = new Intl.PluralRules('en-US');
const monthYear = new Intl.DateTimeFormat('en-US', { month: 'short', year: 'numeric' });
function monthsBetween(start, end) {
const [sy, sm] = start.split('-').map(Number);
const [ey, em] = end.split('-').map(Number);
return (ey - sy) * 12 + (em - sm);
}
function formatDuration(start, end) {
const months = monthsBetween(start, end ?? TODAY);
if (months < 1) return 'less than a month';
const years = Math.floor(months / 12);
const rest = months % 12;
const parts = [];
if (years > 0) parts.push(years + ' ' + yearWords[plural.select(years)]);
if (rest > 0) parts.push(rest + ' mo.');
return parts.join(' ');
}
function formatMonth(value) {
const [year, month] = value.split('-').map(Number);
return monthYear.format(new Date(year, month - 1, 1));
}
const initialProfiles = {
redbeard: {
handle: 'redbeard', name: 'Captain Redbeard', headline: 'Captain and navigator on the Black Pearl',
experience: [
{ id: 'e1', title: 'Captain', company: 'Black Pearl', startDate: '2023-03' },
{ id: 'e2', title: 'First mate', company: 'Flying Dutchman', startDate: '2018-06', endDate: '2023-02' },
],
skills: [
{ id: 's1', name: 'Navigation', endorsedBy: ['anne', 'jack'] },
{ id: 's2', name: 'Cartography', endorsedBy: ['anne'] },
],
},
anne: {
handle: 'anne', name: 'Anne Bonny', headline: 'First mate, boarding specialist',
experience: [{ id: 'e3', title: 'First mate', company: "Queen Anne's Revenge", startDate: '2024-01' }],
skills: [
{ id: 's4', name: 'Boarding', endorsedBy: ['jack'] },
{ id: 's5', name: 'Fencing', endorsedBy: [] },
],
},
};
// The "server": the same rules as the profileSchema schema in the project.
function validateProfile(values) {
const errors = {};
const name = values.name.trim();
const headline = values.headline.trim();
if (name.length < 2) errors.name = 'Enter your name (at least 2 characters).';
else if (name.length > 60) errors.name = 'At most 60 characters.';
if (headline.length < 5) errors.headline = 'Describe yourself in a few words (at least 5 characters).';
else if (headline.length > 120) errors.headline = 'At most 120 characters.';
return { errors, data: { name, headline } };
}
function serverUpdateProfile(values) {
return new Promise((resolve) => setTimeout(() => resolve(validateProfile(values)), 600));
}
// The endorsement "server": it rejects your own skill and a second endorsement.
function canEndorse(viewer, profile, skill) {
return viewer !== profile.handle && !skill.endorsedBy.includes(viewer);
}
export default function App() {
const [profiles, setProfiles] = useState(initialProfiles);
const [shown, setShown] = useState('anne');
const [values, setValues] = useState({ name: initialProfiles.redbeard.name, headline: initialProfiles.redbeard.headline });
const [errors, setErrors] = useState({});
const [pending, setPending] = useState(false);
const profile = profiles[shown];
const isOwn = shown === VIEWER;
const endorse = (skill) => {
if (!canEndorse(VIEWER, profile, skill)) return;
setProfiles((prev) => ({
...prev,
[shown]: {
...profile,
skills: profile.skills.map((s) => (s.id === skill.id ? { ...s, endorsedBy: [...s.endorsedBy, VIEWER] } : s)),
},
}));
};
const handleSubmit = async (event) => {
event.preventDefault();
setPending(true);
const result = await serverUpdateProfile(values);
setPending(false);
setErrors(result.errors);
if (Object.keys(result.errors).length === 0) {
setProfiles((prev) => ({ ...prev, redbeard: { ...prev.redbeard, ...result.data } }));
setValues(result.data);
}
};
return (
<div className="min-h-screen bg-gray-100 p-4 text-gray-900">
<div className="mx-auto max-w-2xl space-y-4">
<div className="flex gap-2 text-sm">
<span className="py-1">Viewing:</span>
{Object.values(profiles).map((p) => (
<button
key={p.handle}
type="button"
onClick={() => setShown(p.handle)}
className={shown === p.handle ? 'rounded-full bg-blue-600 px-3 py-1 text-white' : 'rounded-full border border-gray-300 bg-white px-3 py-1'}
>
{p.handle === VIEWER ? 'Your profile' : p.name}
</button>
))}
</div>
<section className="rounded-lg border border-gray-200 bg-white p-5">
<h1 className="text-2xl font-bold">{profile.name}</h1>
<p className="text-gray-700">{profile.headline}</p>
<h2 className="mt-4 font-bold">Experience</h2>
<ul className="divide-y divide-gray-200">
{profile.experience.map((job) => (
<li key={job.id} className="py-2">
<p className="font-semibold">{job.title}, {job.company}</p>
<p className="text-sm text-gray-500">
{formatMonth(job.startDate)} - {job.endDate ? formatMonth(job.endDate) : 'present'} · {formatDuration(job.startDate, job.endDate)}
</p>
</li>
))}
</ul>
<h2 className="mt-4 font-bold">Skills</h2>
<ul className="divide-y divide-gray-200">
{profile.skills.map((skill) => {
const endorsed = skill.endorsedBy.includes(VIEWER);
return (
<li key={skill.id} className="flex items-center justify-between py-2">
<span>{skill.name} <span className="text-sm text-gray-500">(endorsements: {skill.endorsedBy.length})</span></span>
{!isOwn && (
<button
type="button"
disabled={endorsed}
onClick={() => endorse(skill)}
className="rounded-full border-2 border-blue-600 px-3 py-0.5 text-sm font-semibold text-blue-600 disabled:border-gray-200 disabled:text-gray-500"
>
{endorsed ? 'Endorsed' : '+ Endorse'}
</button>
)}
</li>
);
})}
</ul>
</section>
{isOwn && (
<form onSubmit={handleSubmit} noValidate className="space-y-3 rounded-lg border border-gray-200 bg-white p-5">
<h2 className="font-bold">Edit profile</h2>
{[['name', 'Full name'], ['headline', 'Professional headline']].map(([field, label]) => (
<div key={field}>
<label htmlFor={field} className="block font-semibold">{label}</label>
<input
id={field}
value={values[field]}
onChange={(e) => setValues({ ...values, [field]: e.target.value })}
aria-invalid={errors[field] ? true : undefined}
aria-describedby={errors[field] ? field + '-error' : undefined}
className="w-full rounded-lg border border-gray-300 px-3 py-2"
/>
{errors[field] && <p id={field + '-error'} className="text-sm text-red-600">{errors[field]}</p>}
</div>
))}
<button type="submit" disabled={pending} className="rounded-full bg-blue-600 px-5 py-2 font-semibold text-white disabled:bg-gray-300">
{pending ? 'Saving...' : 'Save profile'}
</button>
</form>
)}
</div>
</div>
);
}
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. Which fields do NOT belong to the Profile type in Crew Connections?
2. What will formatDuration("2023-03", "2025-08") return?
These are 2 of 6 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Code editor
Professional profile header
- Vertical ordering
Arrange the elements of the profile header (ProfileHeader) from top to bottom:
- Click in order
Arrange reading the field errors from the validation result: z.flattenError(result.error).fieldErrors
- Click in order
Arrange reading the number of connections from the profile: profile.connections
- Click in order
Arrange attaching the action to the endorsement form: endorseSkill.bind(null, profile.handle, skill.id)
- Vertical ordering
Arrange what happens after clicking + Endorse on someone else's profile:
- Code editor
Skills section component
- Horizontal ordering
Arrange in one line the date row from ExperienceSection: formatMonth(job.startDate) - present · formatDuration(...)
- Vertical ordering
Arrange the steps of the updateProfile Server Action:
Tasks after this lesson
- QuestionQuiz: Profile type fields
- QuestionQuiz: formatDuration result
- Coding taskPractice: Profile header
- QuestionQuiz: The headline field
- QuestionQuiz: A job that is ongoing
- Put in orderSorting: Profile header from the top
- Click in orderSorting: Reading validation errors
- Click in orderSorting: Reading profile.connections
- Click in orderSorting: An action with extra arguments
- QuestionQuiz: Skill endorsements
- QuestionQuiz: recommendations vs endorsements
- Put in orderSorting: Endorsing a skill on the server
- Coding taskPractice: Skills with endorsements
- Put in orderSorting: Employment date line
- Put in orderSorting: Steps of the updateProfile action