Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 16

Crafting LinkedIn Posts: Hooks and Structure

Recommended resources

Hello! Welcome back to the course.

In our last lesson, we built a "Writer Agent" capable of generating text that aligns with your specific brand voice. We now have a tool that can take a structured outline and produce content in an authoritative, clear, and direct style. This was a crucial step in moving beyond generic AI output.

Today, we'll specialize this capability for a specific, high-impact platform: LinkedIn. This lesson directly addresses the learning outcome: Design prompts that generate LinkedIn posts with effective hooks and professional structure.

LinkedIn is not a generic text field; it has its own culture and algorithm. A post's success often hinges on its first two lines. Your goal is to create engaging content, and on LinkedIn, engagement starts with a hook that stops the scroll and a structure that delivers value clearly and professionally. We will dissect what makes a LinkedIn post effective and then engineer our prompts to build them automatically.

By the end of this lesson, you will have designed and implemented a specialized "LinkedIn Post Generator" in TypeScript.

The Anatomy of a High-Performing LinkedIn Post

Before we can ask an LLM to write a great LinkedIn post, we need to define what "great" means in this context. It generally comes down to two things: a powerful hook and a clear, value-driven structure.

Part 1: The Scroll-Stopping Hook

The first line of your post is the single most important element. It's what people see before they click "...see more". Its only job is to earn that click.

To understand the mechanics of a great hook, let's explore the psychology behind them.

What Are the Most Effective Hooks for LinkedIn Posts?

The article 'What Are the Most Effective Hooks for LinkedIn Posts?' from Pressmaster.ai provides an excellent breakdown of why hooks work and the common formats they take.

Please read the sections 'The Anatomy of High-Performing LinkedIn Hooks' and 'Hook Formats That Consistently Perform'. Focus on these key concepts: Psychological Triggers: Pay attention to the definitions of the Curiosity Gap, Pattern Interrupt, and Counterintuitive Claim. These are concepts we will translate into our prompts. Proven Formats: Note the structures like 'The Direct Question' and 'The Bold Statement'. These are repeatable patterns our LLM can learn.

A great hook makes a promise, creates tension, or challenges a belief. For example, a post about your work might start with:

LinkedIn Post Hook Example
This image shows a LinkedIn post by Ben Goodey. The headline, "Steal my internal link audit process (and free template):", is explicitly labeled as the 'Hook'. It's effective because it's direct, offers high value, and uses an active verb ('Steal') to grab attention.

Part 2: Professional Structure with Frameworks

Once the hook has done its job, the body of the post must deliver on the promise. A random wall of text won't work. Successful posts often follow proven narrative structures, or frameworks, that make the content easy to digest and professionally formatted.

How to Write LinkedIn Posts That Get 100k Views in 15 Minutes

The video 'How to Write LinkedIn Posts That Get 100k Views in 15 Minutes' by Will McTighe introduces three powerful frameworks perfect for technical, thought-leadership content.

Watch the segments explaining these three frameworks: Problem-Agitate-Solution (01:52 - 03:29): Ideal for educational content. You'll state a problem your audience faces (e.g., a common bug, architectural flaw), explain why it's painful, and then present your solution. Story-Lesson-Application (03:29 - 04:55): Perfect for sharing personal experience. You can tell a brief story about a project, extract a key lesson, and explain how others can apply it. Case Study (04:55 - 06:41): Excellent for demonstrating the impact of your work. You show the 'before' state, the 'after' state, and explain what changed.

These frameworks give your content a logical flow and transform a simple idea into a compelling narrative. For your goal of making programming work engaging, these are invaluable tools. For example, you could use the Problem-Agitate-Solution framework to discuss how you fixed a recurring bug in your event-driven architecture.

A Playbook of Post Types

The frameworks from the video are just the beginning. There's a wide variety of post structures you can use, each suited for different goals.

10 Powerful LinkedIn Posts Examples

The article '10 Powerful LinkedIn Posts Examples' from Postiv.ai serves as a tactical playbook, offering detailed templates for various post types.

Please review the following post types and their templates. These are highly relevant for creating technical thought-leadership content: 1. The Problem-Solution Post: Reinforces the framework from the video. 4. The Data-Driven Insight Post: Useful when you have metrics about system performance or a project's outcome. 5. The 'Hot Take' or Contrarian Opinion Post: Aligns perfectly with the contrarian aspect of your brand voice. 7. The Before/After or Case Study Post: Another excellent format for showcasing tangible results from your engineering work.

Now that you have a mental library of what a good LinkedIn post looks like, let's codify this knowledge and teach our AI agent to do it.


Activity: Building the LinkedInPostGenerator

We will now create a new function, generateLinkedInPost, that specializes our Writer Agent. This function will take a content outline (from our previous modules) and a desired framework, then construct a highly specific prompt to generate a ready-to-use LinkedIn post.

Create a new file in your project: src/generateLinkedInPost.ts.

// src/generateLinkedInPost.ts

import OpenAI from 'openai';
import { systemRole, voiceRules, fewShotExamples } from './brandVoice'; // Assuming these are in a file in the same directory
// Assume ContentOutline is a type you have defined
// import { ContentOutline } from './createOutline'; 

// Initialize your LLM client
const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

// Define the supported post frameworks
export type LinkedInFramework = 'ProblemSolution' | 'DataDrivenInsight' | 'ContrarianOpinion' | 'CaseStudy';

// Define framework-specific instructions
const frameworkInstructions: Record<LinkedInFramework, string> = {
  ProblemSolution: `
    **Framework: Problem-Solution**
    1.  **Problem:** Start with a hook that states a common, frustrating problem your target audience (other developers/engineers) faces.
    2.  **Agitate:** Briefly explain why this problem is painful or what common, flawed approaches people take.
    3.  **Solution:** Clearly present your actionable solution or insight.
    4.  **CTA:** End with a question to spark conversation about their experience with the problem.
  `,
  DataDrivenInsight: `
    **Framework: Data-Driven Insight**
    1.  **Hook:** Start with a startling or surprising statistic or data point from the outline.
    2.  **Context:** Explain what this data implies for your audience.
    3.  **Takeaway:** Provide a brief, actionable takeaway based on the data.
    4.  **CTA:** End with a question asking if this data aligns with their experience.
  `,
  ContrarianOpinion: `
    **Framework: Contrarian Opinion ('Hot Take')**
    1.  **Hook:** Start with your contrarian stance, directly challenging a common belief in the tech industry.
    2.  **Argument:** Explain your reasoning. Why is the conventional wisdom wrong? Use your experience to back it up.
    3.  **Alternative:** Provide a nuanced alternative or a new way of thinking.
    4.  **CTA:** End by inviting debate: "What's your take?" or "Am I missing something?".
  `,
  CaseStudy: `
    **Framework: Before/After Case Study**
    1.  **Hook:** Lead with the single most impressive metric or outcome (e.g., "We cut latency by 80%...").
    2.  **Before:** Briefly describe the problem state or the challenge.
    3.  **After:** Detail the key strategic change or technical implementation that led to the result.
    4.  **CTA:** End with an offer to share more insights or ask a related question.
  `
};

/**
 * Generates a LinkedIn post from a content outline using a specific framework.
 * @param outline - The structured content outline.
 * @param framework - The post structure to use.
 * @returns The generated LinkedIn post as a Markdown string.
 */
export async function generateLinkedInPost(
  outline: any, // Use your ContentOutline type here
  framework: LinkedInFramework
): Promise<string | null> {

  const outlineString = JSON.stringify(outline, null, 2);
  const specificInstructions = frameworkInstructions[framework];

  const systemPrompt = `
    ${systemRole}

    You are a specialist in writing viral LinkedIn posts for a technical audience. Your task is to write a LinkedIn post based on a JSON outline.

    **Overall Rules:**
    1.  **Hook is everything:** The first 1-2 lines must be incredibly compelling. They should create curiosity, state a bold claim, or present a surprising fact.
    2.  **Readability:** Use short sentences (avg. 10-15 words). Use plenty of white space (a new line for almost every sentence).
    3.  **No Hashtags:** Do not include any hashtags in the output.
    4.  **Tone:** Strictly adhere to the brand voice rules provided.
    
    ${voiceRules}

    Today, you will write a post using the following structure:
    ${specificInstructions}

    Here are examples of the writing style:
    ${fewShotExamples}
  `;

  try {
    const response = await openai.chat.completions.create({
      model: "gpt-4-turbo",
      messages: [
        { role: "system", content: systemPrompt },
        { 
          role: "user", 
          content: `
            Write a LinkedIn post based on the following outline, using the **${framework}** framework.

            **Content Outline:**
            \`\`\`json
            ${outlineString}
            \`\`\`
          `
        }
      ],
      temperature: 0.7,
    });

    const content = response.choices[0].message.content;
    if (!content) {
      throw new Error("Empty response from LLM.");
    }
    
    console.log(`Successfully generated LinkedIn post using ${framework} framework.`);
    return content;

  } catch (error) {
    console.error(`Error during LinkedIn post generation:`, error);
    return null;
  }
}

Deconstructing the Prompt

Let's break down why this systemPrompt is so effective:

  1. Specialized Role: It starts by refining the persona: "You are a specialist in writing viral LinkedIn posts for a technical audience."
  2. Platform-Specific Rules: It adds rules unique to LinkedIn, such as the critical importance of the hook and the need for short sentences and whitespace.
  3. Framework Injection: It dynamically includes the instructions for the chosen framework (e.g., ProblemSolution), giving the LLM a clear, step-by-step structure to follow.
  4. Inherited Brand Voice: It re-uses the systemRole, voiceRules, and fewShotExamples from your brandVoice.ts module, ensuring stylistic consistency.

This layered approach gives you precise control. You can now generate a post by calling the function with an outline and your chosen framework:

// Example usage:
// const myTrendOutline = { /* ... your outline from the previous module ... */ };
// const linkedInPost = await generateLinkedInPost(myTrendOutline, 'ContrarianOpinion');
// console.log(linkedInPost);

As a final piece of inspiration, this image shows a variety of prompt ideas for different parts of a LinkedIn post, reinforcing the patterns we've discussed today.

9 ChatGPT Prompts For Content on LinkedIn
This cheat sheet displays nine distinct ChatGPT prompts for generating different types of LinkedIn content, from hooks to carousels. It's a useful reference for seeing how different instructions can be used to target specific content needs.

Conclusion

In this lesson, you've moved from a general-purpose writer to a platform-specific content generator. You now have a robust system for creating LinkedIn posts that are not only on-brand but are also engineered for engagement by using proven hooks and professional structures.

Key Takeaways:

  • LinkedIn is a specialized platform: Effective posts require a strong hook and a scannable, value-driven structure.
  • Frameworks are your friend: Using structures like "Problem-Solution" or "Contrarian Opinion" provides a reliable skeleton for your content.
  • Prompt engineering is about layers: You can create powerful, specialized prompts by combining a general brand voice with platform-specific rules and dynamic, task-specific instructions.
  • Code is your scaffolding: By defining frameworks and prompts in TypeScript, you make your content generation system modular, predictable, and easy to extend.

Preview of the next lesson:
A short-form post is great for capturing attention, but sometimes a topic deserves a deeper dive. In the next lesson, "Generate a long-form LinkedIn article from a content outline, applying brand voice and narrative refinement," we will adapt our generation process to create comprehensive articles that establish you as a true thought leader on a subject.