DEV Community

Alex Chen
Alex Chen

Posted on

I Built an AI Writing Assistant (And It Changed How I Create Content)

I Built an AI Writing Assistant (And It Changed How I Create Content)

How I built a tool that helps me write better technical articles — faster.

The Problem

My writing process before:
1. Stare at blank page for 30 minutes
2. Write a terrible first draft
3. Spend 2 hours editing it into something readable
4. Realize I forgot key points → rewrite
5. Publish → get 3 views

Total time per article: 4-6 hours
Quality: Inconsistent
Output: 2-3 articles per week
Enter fullscreen mode Exit fullscreen mode

The Solution

// I built a simple AI writing assistant that:
// 1. Generates outlines from a topic
// 2. Expands each section with code examples
// 3. Suggests improvements to my drafts
// 4. Checks for common issues (missing examples, unclear explanations)

const OpenAI = require('openai');
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

async function generateOutline(topic) {
  const response = await openai.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [
      {
        role: 'system',
        content: `You are a technical writing assistant. Generate detailed article outlines for developer tutorials.

Rules:
- Target audience: intermediate developers
- Each section should have a clear purpose
- Include where code examples should go
- Keep articles under 1500 words unless complex topic
- Always include practical, runnable code`
      },
      {
        role: 'user',
        content: `Create an outline for: ${topic}`
      }
    ],
    temperature: 0.7,
  });

  return response.choices[0].message.content;
}

async function expandSection(sectionTitle, context) {
  const response = await openai.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [
      {
        role: 'system',
        content: `Expand this section of a technical article. Include:
1. Clear explanation (2-3 paragraphs)
2. At least one code example that RUNS
3. Common pitfalls to mention
4. A "quick reference" summary at the end

Write in a conversational, helpful tone. Like you're explaining to a colleague.`
      },
      {
        role: 'user',
        content: `Section: ${sectionTitle}\n\nContext: This is part of an article about ${context}.\n\nWrite the full section content.`
      }
    ],
    temperature: 0.7,
  });

  return response.choices[0].message.content;
}
Enter fullscreen mode Exit fullscreen mode

My New Workflow

// Step 1: Generate outline
const outline = await generateOutline('CSS Grid Complete Guide');

// Output:
// ## CSS Grid Complete Guide
// 
// ### Introduction (100 words)
// - What is Grid? Why use it over Flexbox?
// 
// ### Core Concepts (300 words)
// - Grid container vs grid items
// - Grid lines, tracks, areas
// [CODE EXAMPLE: Basic grid setup]
//
// ### ... etc

// Step 2: Expand each section
for (const section of parseOutline(outline)) {
  const content = await expandSection(section.title, 'CSS Grid');
  article += formatContent(content);
}

// Step 3: Review and edit (I still do this myself!)
// The AI gives me ~80% quality. I add:
// - Personal experience and war stories
// - Specific real-world examples from my projects
// - My voice and style
// - Better code examples than AI generates
// - Corrections (AI gets things wrong sometimes!)

// Step 4: Quality checks
const issues = await checkArticle(article);
// Issues found:
// - Section "Responsive Design" has no code example ← FIX
// - Introduction is too long (200+ words) ← TRIM
// - Missing "common mistakes" section ← ADD
// - Code example on line 45 won't actually run ← FIX
Enter fullscreen mode Exit fullscreen mode

The Article Checker

async function checkArticle(markdown) {
  const response = await openai.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [
      {
        role: 'system',
        content: `You are a technical editor. Check this article for issues.
Return JSON array of issues found:

{
  "issues": [
    { "type": "missing_code", "section": "...", "suggestion": "..." },
    { "type": "unclear", "text": "...", "suggestion": "..." },
    { "type": "error", "problem": "...", "fix": "..." },
    { "type": "improvement", "suggestion": "..." }
  ]
}`
      },
      {
        role: 'user',
        content: markdown
      }
    ],
    temperature: 0.3,
  });

  return JSON.parse(response.choices[0].message.content);
}
Enter fullscreen mode Exit fullscreen mode

Results After Using the Assistant

Before:
- Time per article: 4-6 hours
- Articles per week: 2-3
- Quality: Inconsistent
- Blank page anxiety: Every single time

After:
- Time per article: 1-2 hours (AI draft + my edits)
- Articles per day: 5-10 (when I push hard)
- Quality: Consistent (same structure + my polish)
- Blank page anxiety: Gone (AI gives me starting point)
Enter fullscreen mode Exit fullscreen mode

What the AI Can't Do (Yet)

❌ Personal stories and experience
❌ Real screenshots from my actual projects
❌ Knowing what resonates with MY audience
❌ Catching subtle technical inaccuracies (sometimes adds them!)
❌ Understanding the broader context of my brand/strategy
❌ Being opinionated in an interesting way
❌ Reading and responding to comments authentically

✅ These are still MY job — and they're the parts that matter most
Enter fullscreen mode Exit fullscreen mode

Cost Analysis

GPT-4o-mini pricing (as of 2026):
- Input: $0.15 / 1M tokens
- Output: $0.60 / 1M tokens

Cost per article:
- Outline generation: ~$0.002
- Section expansion (5 sections): ~$0.01
- Quality check: ~$0.003
- Total: ~$0.015 per article (1.5 cents!)

For 100 articles: ~$1.50 total
For 500 articles: ~$7.50 total

Cheapest content creation investment I've ever made.
Enter fullscreen mode Exit fullscreen mode

The Full Tool Stack

// My complete writing pipeline:

// 1. Topic generator (from trending tech topics)
async function generateTopics(count = 10) {
  // Analyze trending repos, HN, Dev.to popular
  // Return topics likely to get engagement
}

// 2. Outline generator
// (shown above)

// 3. Content expander
// (shown above)

// 4. Code validator
// Runs code examples through a sandbox to verify they work
function validateCode(codeBlock) {
  // Extract code from markdown
  // Run in isolated environment
  // Check output matches expected
  // Return pass/fail + actual output
}

// 5. SEO optimizer
async function optimizeSEO(article, keyword) {
  // Suggest title variations
  // Check keyword density
  // Suggest meta description
  // Recommend internal links
}

// 6. Publisher
async function publishToDevTo(article) {
  // Auto-format for Dev.to
  // Upload via API or browser automation
  // Schedule optimal publish time
}

// Pipeline orchestration
async function writeArticle(topic) {
  console.log(`\n📝 Starting: ${topic}`);

  const outline = await generateOutline(topic);
  console.log('  ✅ Outline generated');

  let content = '';
  for (const section of parseOutline(outline)) {
    const expanded = await expandSection(section.title, topic);
    content += expanded + '\n\n';
  }
  console.log('  ✅ All sections written');

  const issues = await checkArticle(content);
  if (issues.length > 0) {
    console.log(`  ⚠️  Found ${issues.length} issues to review`);
  }

  return { content, issues, outline };
}
Enter fullscreen mode Exit fullscreen mode

Lessons Learned

1. AI is a force multiplier, not a replacement
   - My best articles come from AI draft + heavy human editing
   - Pure AI articles feel generic and flat

2. Structure matters more than prose
   - Good outline → good article (most of the time)
   - Bad outline → garbage no matter how good the writing

3. Always fact-check code examples
   - AI generates plausible-looking but broken code ~20% of time
   - I have a sandbox that runs every code block before publishing

4. Find your ratio
   - Too much AI → robotic, impersonal
   - Too little AI → slow, inconsistent
   - My sweet spot: AI does 70%, I do 30% (but the critical 30%)

5. Use different prompts for different article types
   - Tutorial: More code-focused, step-by-step
   - Opinion piece: Less AI help (my voice matters more)
   - Reference/Cheat sheet: Heavy AI help (structure is everything)
Enter fullscreen mode Exit fullscreen mode

Are you using AI in your content workflow? What's working for you?

Follow @armorbreak for more content on building with AI.

Top comments (0)