Vibe coding with Claude Code course · Module 7: LinkedIn clone

The crew's notice board: a professional feed and a network of connections

9 min read
In this lesson9

On Twitter people write about breakfast, and in Crew Connections about a promotion to first mate. A professional feed works like any other, only the posts are about work: a new position, an anniversary on board, an article about tide charts. It is a difference of tone, not of mechanics: LinkedIn is professional content, job offers and resumes, and Twitter is personal matters and casual chat. Next to the feed stands a network of connections, a list of pirates you know, with the number of mutual friends.

Request for Claude Code

This is several files and two pages, so you start with a plan:

Request for Claude Code:

/plan Add a feed /feed and a network of connections /network. A post as a
union discriminated by the type field: text, article, job_change,
work_anniversary, each type with its own data. The post card has a
separate branch for each type, and the compiler must report a missing
branch. Publication time as "2 hours ago" through formatTimeAgo in
lib/format.ts with Intl.RelativeTimeFormat, tests first. A like only
in the browser for now. /network: contact cards and a search with the
phrase in the address, case-insensitive. I will build the new-post form
with a skill.

After you approve the plan and the build, you type the same recipe for the third time: /new-form feed post. To the question about fields you answer briefly: content up to 3000 characters, and the type text, the author and the date are set by the server. This produces PostForm above the feed and the createPost action, built like the two previous forms.

What Claude wrote: the post in types

Open types/feed.ts in Cursor. The fields shared by all posts live in PostBase: an id, the author (handle, name, headline), content, createdAt as an ISO string and counters of likes, comments and shares. On that foundation stand four shapes:

export type PostType = "text" | "article" | "job_change" | "work_anniversary";

export type FeedPost =
  | (PostBase & { type: "text" })
  | (PostBase & { type: "article"; article: { title: string; url: string } })
  | (PostBase & { type: "job_change"; jobChange: { position: string; company: string } })
  | (PostBase & { type: "work_anniversary"; anniversary: { years: number; company: string } });

This is the same discriminated union as VideoSource from lesson 5_1: the type field tells you which shape you hold. A job_change post always has jobChange, and a plain text post has no extras. The older idea of an optional jobChange? field on every post allowed saving a job change without a new position, and TypeScript would not notice.

What Claude wrote: a branch for each type

Open components/feed/PostHighlight.tsx. The highlight above the post content depends on the type:

switch (post.type) {
  case "text":
    return null;
  case "job_change":
    return (
      <p className="rounded-lg border border-blue-200 bg-blue-50 p-3">
        New position: <strong>{post.jobChange.position}</strong> · {post.jobChange.company}
      </p>
    );
  // article and work_anniversary similar
  default: {
    const unhandled: never = post;
    return unhandled;
  }
}

never is a type that no value has. When every type has its own case, nothing reaches default and the assignment passes. We checked it: after adding the type "poll" to the union without a branch, npx tsc --noEmit reported Type 'PostBase & { type: "poll"; ... }' is not assignable to type 'never'. A plain default: return null would hide the new type silently, and a poll would look like an empty post.

What Claude wrote: publication time

Open lib/format.ts. Intl.RelativeTimeFormat is JavaScript's built-in relative time formatter, which knows the grammar of the language:

const relative = new Intl.RelativeTimeFormat("en-US", { numeric: "auto" });

export function formatTimeAgo(iso: string, now = new Date()): string {
  const seconds = Math.round((new Date(iso).getTime() - now.getTime()) / 1000);
  for (const [unit, size] of steps) {
    if (Math.abs(seconds) >= size) return relative.format(Math.round(seconds / size), unit);
  }
  return "just now";
}

steps is a list of units from a year down to a minute with the number of seconds in each. The loop takes the first unit that fits the difference, and a negative number means the past: relative.format(-3, "day") gives "3 days ago". numeric: "auto" turns "1 day ago" into "yesterday" and "1 week ago" into "last week", while "2 days ago" stays as it is. A difference below a minute is "just now". The now parameter serves the tests, and the function lives in one place from which the post card imports it. The tests look like this:

it("says yesterday instead of 1 day ago", () => {
  expect(formatTimeAgo("2026-11-13T12:00:00Z", now)).toBe("yesterday");
  expect(formatTimeAgo("2026-11-11T12:00:00Z", now)).toBe("3 days ago");
});

The first run ended with ReferenceError: formatTimeAgo is not defined: Claude added the tests to the file but did not add the function to the import at its top. You also remember the no-break space from lesson 5_1. There is none here: we checked the character codes, and RelativeTimeFormat for en-US puts regular spaces in Node 24 and in Chrome, so expectations with a regular space are right.

What Claude wrote: the post card

Open components/feed/FeedPostCard.tsx. The card header shows the author and the time:

<header className="flex gap-3 p-4 pb-2">
  <Avatar name={post.author.name} />
  <div>
    <h2 className="font-semibold">{post.author.name}</h2>
    <p className="text-sm text-gray-600">{post.author.headline}</p>
    <p className="text-xs text-gray-500">{formatTimeAgo(post.createdAt)}</p>
  </div>
</header>

Under the header stands PostHighlight, the content with the class whitespace-pre-wrap, which keeps paragraphs, and a line "Likes: 42 · Comments: 7 · Shares: 2". At the bottom is a row of actions: Like, Comment, Repost and Send. A repost shares someone else's post in your network, and Send passes it on in a private message. Like is a separate small Client Component LikeButton with a liked state: a click calls setLiked(!liked), and the button gets the class text-blue-600. The counter does not change, because the like does not reach the server yet. The rest of the card stays a Server Component.

The third form from the same recipe

Open app/feed/actions.ts and compare it with the profile action: the same steps in the same order. createPost takes the pirate from getCurrentUser() and copies the author's name and headline from their profile, so the form sends only the content. After success it does not redirect, because the post should appear right here, at the top of the feed: it calls revalidatePath("/feed") and returns empty values, so the field clears. After an error the typed text stays in the field. The recipe already has the rules added in lesson 6_2, so check in PostForm that it imports only Field and the action, and nothing that reads the disk. Three forms, one recipe: that is what a skill that pays off looks like.

The network of connections

A connection (Connection in types/network.ts) is a handle, a name, a headline, the date the connection was made and mutualConnections, the number of mutual friends, which helps judge whether you know someone. The search is a pure function in lib/search.ts:

export function searchConnections(connections: Connection[], query: string): Connection[] {
  const phrase = query.trim().toLocaleLowerCase("en-US");
  if (!phrase) return connections;
  return connections.filter((person) =>
    `${person.name} ${person.headline}`.toLocaleLowerCase("en-US").includes(phrase),
  );
}

It searches the name and the headline at once, and toLocaleLowerCase("en-US") lowercases both the phrase and the text the same way, so a test with "ANNE" finds Anne Bonny. An empty phrase returns the whole network. The phrase lives in the address (/network?q=officer) as in lesson 4_5: the page reads it through await searchParams, and the field has key={query}. Such an address has two advantages: a link with the results can be sent to a friend from the crew, and the browser's Back button returns to the previous search. The contact card has, from the top, an avatar, the name with a link to the profile, the headline, and below that "Mutual connections: 12" and a Message button.

Captain's review

  1. A clock stopped at build time. Run npm run build and look at the mark next to /feed. In our run it was ○: the feed does not ask about the session, so the build rendered it once, like the edit page in lesson 6_1. A new post was still "just now" after a minute and a half, and "10 hours ago" did not grow. The fix is await connection() at the start of the feed page; after a new build /feed shows ƒ.
  2. The whole card in the browser. A typical agent idea is "use client" at the top of FeedPostCard, because the button needs useState. Then the card and formatTimeAgo travel to the browser, and the time is computed twice: on the server and during hydration, when React attaches events to the ready HTML. The documentation requires both results to match, and at a minute boundary they can drift apart. It also advises marking "use client" only on the files of interactive components, as Claude did with LikeButton.
  3. An empty post. Send only spaces: the server answers "Write something before you publish.", and the feed does not change. The field also has maxLength, so the browser will not let you type 3001 characters, but the schema has its own limit anyway, because a request can be sent bypassing the form.
  4. A second pair of eyes. Before the commit run /code-review from lesson 2_9 and reject remarks outside the scope of this lesson.

Next step

When the review passes, ask for a commit, for example "Professional feed and network of connections". Then a small step:

A like must survive a page refresh: save it on the server like the
endorsement in endorseSkill, at most once per pirate. The counter
must show the new number right away. Tests of the rule first.

In the editor below waits a feed in miniature with four post types and a slider that moves the clock, plus a contact search. Move the clock by a week and watch "yesterday" turn into "last week".

Remember: the feed is the same waves as everywhere, only ships with orders sail on them, and the clock at every post must keep ticking, not stand still since the day of launch.

Code for this lesson: App.jsx
// A professional feed in miniature: four post types, relative time and a contact search.
// The slider moves "now" so you can see how formatTimeAgo changes the text.
import { useState } from 'react';

const BASE = new Date('2026-11-14T12:00:00Z');
const relative = new Intl.RelativeTimeFormat('en-US', { numeric: 'auto' });
const steps = [
  ['year', 365 * 24 * 3600],
  ['month', 30 * 24 * 3600],
  ['week', 7 * 24 * 3600],
  ['day', 24 * 3600],
  ['hour', 3600],
  ['minute', 60],
];

const yearWords = { one: 'year', other: 'years' };
const plural = new Intl.PluralRules('en-US');
const formatYears = (years) => years + ' ' + yearWords[plural.select(years)];

function formatTimeAgo(iso, now) {
  const seconds = Math.round((new Date(iso).getTime() - now.getTime()) / 1000);
  for (const [unit, size] of steps) {
    if (Math.abs(seconds) >= size) return relative.format(Math.round(seconds / size), unit);
  }
  return 'just now';
}

const posts = [
  { id: 'p0', type: 'text', author: 'Captain Redbeard', headline: 'Captain of the Black Pearl', content: 'Looking for a boatswain for the morning watch.', createdAt: '2026-11-14T11:59:40Z', likes: 3 },
  { id: 'p1', type: 'job_change', author: 'Anne Bonny', headline: 'First mate', content: 'New deck, new crew!', jobChange: { position: 'First mate', company: "Queen Anne's Revenge" }, createdAt: '2026-11-13T09:00:00Z', likes: 42 },
  { id: 'p2', type: 'work_anniversary', author: 'Captain Redbeard', headline: 'Captain of the Black Pearl', content: 'Three years at the helm.', anniversary: { years: 3, company: 'Black Pearl' }, createdAt: '2026-11-12T10:00:00Z', likes: 18 },
  { id: 'p3', type: 'article', author: 'Calico Jack', headline: 'Expedition cartographer', content: 'I wrote down how to read old maps.', article: { title: 'Tide charts for beginners' }, createdAt: '2026-11-01T16:00:00Z', likes: 9 },
];

const connections = [
  { handle: 'anne', name: 'Anne Bonny', headline: 'First mate, boarding specialist', mutualConnections: 12 },
  { handle: 'jack', name: 'Calico Jack', headline: 'Expedition cartographer', mutualConnections: 5 },
  { handle: 'luke', name: 'Luke Gray', headline: 'Ship carpenter from Gdansk', mutualConnections: 1 },
];

function searchConnections(list, query) {
  const phrase = query.trim().toLocaleLowerCase('en-US');
  if (!phrase) return list;
  return list.filter((p) => (p.name + ' ' + p.headline).toLocaleLowerCase('en-US').includes(phrase));
}

// Every type has its own branch. In TypeScript a default with the never type would stop a new type without a branch.
function PostHighlight({ post }) {
  switch (post.type) {
    case 'text':
      return null;
    case 'article':
      return <p className="rounded-lg border border-gray-200 p-2 font-semibold text-blue-700">{post.article.title}</p>;
    case 'job_change':
      return <p className="rounded-lg border border-blue-200 bg-blue-50 p-2">New position: <strong>{post.jobChange.position}</strong> · {post.jobChange.company}</p>;
    case 'work_anniversary':
      return <p className="rounded-lg border border-amber-200 bg-amber-50 p-2">Anniversary: {formatYears(post.anniversary.years)} · {post.anniversary.company}</p>;
    default:
      throw new Error('No branch for type ' + post.type);
  }
}

function LikeButton() {
  const [liked, setLiked] = useState(false);
  return (
    <button type="button" aria-pressed={liked} onClick={() => setLiked(!liked)} className={liked ? 'rounded px-2 py-1 font-semibold text-blue-600' : 'rounded px-2 py-1 text-gray-600'}>
      Like
    </button>
  );
}

export default function App() {
  const [shiftDays, setShiftDays] = useState(0);
  const [query, setQuery] = useState('');
  const now = new Date(BASE.getTime() + shiftDays * 24 * 3600 * 1000);
  const found = searchConnections(connections, query);

  return (
    <div className="min-h-screen bg-gray-100 p-4 text-gray-900">
      <div className="mx-auto max-w-xl space-y-4">
        <label className="block rounded-lg border border-gray-200 bg-white p-3 text-sm">
          Move the clock: +{shiftDays} days
          <input type="range" min={0} max={60} value={shiftDays} onChange={(e) => setShiftDays(Number(e.target.value))} className="w-full" />
        </label>

        {posts.map((post) => (
          <article key={post.id} className="rounded-lg border border-gray-200 bg-white p-4">
            <h2 className="font-semibold">{post.author}</h2>
            <p className="text-sm text-gray-600">{post.headline}</p>
            <p className="text-xs text-gray-500">{formatTimeAgo(post.createdAt, now)}</p>
            <div className="mt-2 space-y-2">
              <PostHighlight post={post} />
              <p>{post.content}</p>
            </div>
            <div className="mt-2 flex justify-around border-t border-gray-200 pt-1 text-sm">
              <LikeButton />
              <span className="px-2 py-1 text-gray-600">Comment</span>
              <span className="px-2 py-1 text-gray-600">Repost</span>
              <span className="px-2 py-1 text-gray-600">Send</span>
            </div>
          </article>
        ))}

        <section className="rounded-lg border border-gray-200 bg-white p-4">
          <h2 className="font-bold">Your network: {found.length}</h2>
          <label htmlFor="q" className="sr-only">Search contacts</label>
          <input id="q" value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Search by name or headline" className="mt-2 w-full rounded-lg border border-gray-300 px-3 py-2" />
          <ul className="mt-2 divide-y divide-gray-200">
            {found.map((person) => (
              <li key={person.handle} className="py-2">
                <p className="font-semibold">{person.name}</p>
                <p className="text-sm text-gray-600">{person.headline}</p>
                <p className="text-xs text-gray-500">Mutual connections: {person.mutualConnections}</p>
              </li>
            ))}
          </ul>
        </section>
      </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. 1. What values does the PostType union have in Crew Connections?

  2. 2. What does PostHighlight show when post.type === "job_change"?

These are 2 of 7 questions for this lesson. Solve the rest in the game.

Hands-on tasks in the game

  • Horizontal ordering

    Arrange in one line the action buttons under a post in FeedPostCard (from left to right):

  • Code editor

    Professional feed post

  • Horizontal ordering

    Arrange in one line creating the formatter: const relative = new Intl.RelativeTimeFormat("en-US", { numeric: "auto" });

  • Vertical ordering

    Arrange the steps of liking a post in LikeButton:

  • Vertical ordering

    Arrange publishing a post through the form above the feed:

  • Horizontal ordering

    Arrange in one line the post statistics from FeedPostCard (separated by a dot ·):

  • Code editor

    Professional network page

  • Click in order

    Arrange the start of the union definition: type PostType = "text" | "article"

  • Click in order

    Arrange the call that toggles liking a post: setLiked(!liked)

  • Horizontal ordering

    Arrange in one line the time row from the FeedPostCard header: <p className="text-xs text-gray-500">{formatTimeAgo(post.createdAt)}</p>

  • Vertical ordering

    Arrange the elements of ConnectionCard from top to bottom:

  1. QuestionQuiz: Post types (PostType)
  2. QuestionQuiz: A job_change post
  3. Put in orderSorting: Actions under a post
  4. Coding taskPractice: Feed post card
  5. Put in orderSorting: A relative time formatter
  6. Put in orderSorting: Liking a post
  7. QuestionQuiz: LinkedIn versus Twitter
  8. QuestionQuiz: mutualConnections
  9. Put in orderSorting: Publishing a post
  10. Put in orderSorting: Post statistics in one line
  11. Coding taskPractice: Connections page
  12. Click in orderSorting: The start of the PostType type
  13. QuestionQuiz: Endorsement checks on the server
  14. Click in orderSorting: setLiked call
  15. Put in orderSorting: Publication time in the header
  16. QuestionQuiz: The Repost action
  17. Put in orderSorting: Contact card (ConnectionCard)
  18. QuestionQuiz: The post author header

Useful articles