Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article covers article-writer, a system I built with Claude Code Skills and Subagents to analyze my previous articles and automate article generation.

Background and motivation

Writing articles is enjoyable, but it is also time-consuming. It can be difficult to design each article's structure from scratch or maintain consistency with earlier articles. Qiita and Zenn also have different markup conventions, so each platform's rules need to be kept in mind.

I therefore created a Claude Code Skill called article-writer that analyzes my previous articles and assists with writing new ones.

Problems I wanted to solve

  • Quickly create a basic article structure from templates.
  • Write consistent articles based on patterns in previous work.
  • Support flexible article creation for multiple platforms, including Qiita and Zenn.
  • Make technologies and services I want to learn about easier to understand by writing articles about them.

For example, when writing about an application I built or a specific technology or service, I can have AI prepare the initial draft and then manually expand or revise the parts that need work. This makes writing more efficient. I also wanted to see whether AI could analyze several of my previous articles and carry their distinctive characteristics into new articles.

The goal of writing about technologies and services I want to understand is primarily personal learning. Preparing a draft and deciding whether to publish it are separate matters.

It is important to have a human review the result before finishing.

What is a Claude Code Skill?

See the following resource for more about Claude Skills.

https://zenn.dev/heku/books/claude-code-guide/viewer/customization-skills

A Claude Code Skill is a modular package that provides Claude with knowledge and workflows tailored to a particular domain or task. Skills offer specialized workflows (multistep procedures for a domain), tool integrations (instructions for specific file formats or APIs), domain knowledge (company-specific knowledge, schemas, and business logic), and bundled resources (scripts, reference materials, and assets for complex or repetitive tasks).

Skill structure

Every Skill consists of a required SKILL.md file and optional bundled resources.

text
skill-name/
├── SKILL.md       - 必須
├── scripts/       - 実行可能コード(Python/Bash等)
├── references/    - 必要に応じてコンテキストに読み込むドキュメント
└── assets/        - 出力に使用するファイル(テンプレート等)

SKILL.md is the central file of a Skill and contains YAML metadata with a name and description. The description is particularly important because Claude uses it to determine when the Skill should be invoked.

markdown
---
name: skill-name
description: This skill should be used when...
---

# Skill Name

Instructions for Claude...

Invoking a Skill

Skills can be invoked using /<skill name>.

text
/article-writer EASについて記事を書いてください

Progressive disclosure

Skills use a three-level loading system to manage context efficiently.

flowchart LR
    A[メタデータ<br>name + description] --> B[SKILL.md本文]
    B --> C[バンドルリソース<br>scripts/references/assets]

First, metadata (name and description) is always loaded into context (around 100 words). When the Skill is triggered, the contents of SKILL.md are loaded (ideally fewer than 5,000 words). Finally, Claude Code loads bundled resources as needed.

This design keeps Skills lightweight while allowing them to provide extensive information and tools on demand.

What is a Claude Code Subagent?

See the following resource for more about Subagents.

A Subagent is a dedicated AI worker that runs in a context separate from the main Claude Code session.

Why Subagents are useful

The main Claude Code session has a limited context window (the number of tokens available for conversation history and file content). Analyzing large numbers of articles or writing long documents can quickly fill the main context, leaving little room for other work.

Because Subagents run in an independent context, they offer the following benefits.

  • Less pressure on the main context Loading hundreds or thousands of articles does not consume the main session's context, and the main conversation history can be retained while writing long articles.

  • Parallel processing Multiple Subagents can run simultaneously, allowing analysis and writing to proceed in parallel.

  • Task isolation and reuse A Subagent can be defined for a particular task and invoked repeatedly.

  • Background execution Subagents can run in the background and notify the main session when their work finishes.

Main session versus Subagent

Aspect Main (main session) Subagent
Context Retains the entire conversation with the user Separate context for each task
Role Workflow management and user interaction Computationally intensive work (analysis, writing, generation)
Tasks Skill selection, outline design, quality checks Article analysis, Skill generation, article writing
Input and output Interacts with the user Returns lightweight JSON or Markdown results
Token usage Consumed by conversation history Consumed only during task execution (independently)
flowchart TB
    User[ユーザー] <--> Main[Main<br>メインセッション]
    Main --> |タスク委譲| Sub1[Subagent<br>pattern-extractor]
    Main --> |タスク委譲| Sub2[Subagent<br>skill-writer]
    Sub1 --> |JSON| Main
    Sub2 --> |ファイル生成| Main

Subagent location and definition

Subagents are defined in agent definition files within the .claude/agents/ directory.

Directory structure

text
.claude/
└── agents/
    ├── pattern-extractor.md    # パターン抽出Subagent
    └── skill-writer.md         # スキル生成Subagent

Subagent definition file structure

markdown
---
name: skill-writer
description: パターンJSONからarticle-writerスキルのstyle/とcategories/を生成/更新
tools: Read, Write, Bash, Grep, Glob
model: opus
permissionMode: bypassPermissions
---

skill-writerサブエージェントを起動して、以下のタスクを実行してください:
...

The frontmatter defines the following fields.

  • name Subagent name.
  • description What the Subagent does.
  • tools Tools it can use (Read, Write, Bash, and so on).
  • model Model to use (sonnet, opus, haiku).
  • permissionMode Permissions for file operations.

Setting permissionMode: bypassPermissions allows file operations without user approval.

Invoking a Subagent

Subagents are invoked through slash commands.

text
/pattern-extractor articles/

Executing this command performs the following steps.

  1. Loads .claude/commands/pattern-extractor.md.
  2. The command starts the pattern-extractor Subagent in the background.
  3. The Subagent analyzes articles in its independent context.
  4. It returns the result in JSON format.

The article-writer Skill

What is article-writer?

article-writer is an article-writing assistance system implemented as a Claude Code Skill.

It offers two functions.

  • Writing new articles Automates the process from outline design to drafting, based on references such as URLs and documents. Generates articles with a consistent tone using a style guide extracted from previous articles.

  • Updating existing articles Identifies the parts that need changing and edits them after obtaining user approval. Maintains consistency by following the style guide during updates.

How it works

article-writer consists of three components.

Style guide

The rules used during writing and editing are stored in style/style_guide.md. They define conventions for headings, prose, lists, code blocks, and diagrams.

Category templates

These are article structure templates organized by platform and category. They are generated automatically by analyzing previous articles with /generate-templates.

Each template defines a structure suited to a particular article category (tutorial, explanation, introduction, and so on). When writing a new article, the Skill identifies its category and selects the appropriate template.

User-editable templates

The templates/ directory contains templates for the style guide and history files. Edit these when adding rules manually or customizing the history file format.

File Role
style_guide.md Style guide template
intro_outro.md Introduction and conclusion template
history_template.md Per-article history template
history_template_book.md Per-book history template

Features of article-writer

  • A simple, integrated structure One Skill handles both new articles and updates.

  • Delegation of intensive work to Subagents Heavy tasks such as analyzing large collections of articles run in independent contexts, reducing pressure on the main session.

  • A compact style guide Style files use concise bullet points to limit token consumption.

  • Consistent quality Writing follows style guidelines extracted from previous articles, keeping quality and tone consistent.

Directory structure

text
.claude/
├── commands/                       # スラッシュコマンド
│   ├── pattern-extractor.md        # パターン抽出コマンド
│   └── skill-writer.md             # スキル生成コマンド
├── skills/
│   ├── article-writer/             # 記事執筆スキル(メイン)
│   │   ├── SKILL.md                # スキル定義
│   │   ├── templates/              # ユーザー編集用テンプレート
│   │   │   ├── style_guide.md
│   │   │   ├── intro_outro.md
│   │   │   ├── history_template.md
│   │   │   └── history_template_book.md
│   │   ├── style/                  # スタイルガイド
│   │   │   └── style_guide.md
│   │   ├── history/                # 編集履歴(自動生成)
│   │   │   └── {platform}/         # プラットフォーム別
│   │   │       └── {filename}.md   # 記事単位または本単位
│   │   └── categories/             # カテゴリ別テンプレート(/generate-templatesで更新)
│   │       └── {platform}/         # プラットフォーム別(自動生成)
│   │           └── {category}.md   # カテゴリ別テンプレート
│   └── generate-templates/         # テンプレート生成スキル
│       ├── SKILL.md
│       └── templates/
│           ├── format_rules.md
│           ├── wordings.md
│           ├── intro_outro.md
│           └── category.md
└── agents/
    ├── pattern-extractor.md        # パターン抽出Subagent
    └── skill-writer.md             # スキル生成Subagent

Components

  • article-writer Skill The main Skill for writing new articles and updating existing ones. Invoke it with a prompt such as /article-writer Write an article about ....
  • generate-templates Skill Analyzes previous articles and automatically generates style/ and categories/. Invoke it with an article directory, for example, /generate-templates articles/.
  • Subagents Workers that perform intensive tasks in independent contexts. pattern-extractor extracts patterns from articles and outputs JSON. skill-writer generates style/ and categories/ from the JSON.
  • Commands Slash commands that launch Subagents. /pattern-extractor and /skill-writer are invoked internally by generate-templates.

Workflows

New article workflow

The following workflow applies when creating a new article with /article-writer.

Phase Purpose Operations
Phase 0 Load rules Read style/style_guide.md
Phase 1 Gather information Collect information using WebSearch if references are available
Phase 2 Design outline Identify the category, create an outline, obtain user approval
Phase 3 Write and save Write according to the style guide and save the article
Phase 4 Record history Create a history file documenting the rationale for decisions
Phase 5 Review Check that references and user instructions have been incorporated, and revise omissions
flowchart LR
    P0[Phase 0<br>ルール読み込み] --> P1[Phase 1<br>情報収集]
    P1 --> P2[Phase 2<br>アウトライン設計]
    P2 --> P3[Phase 3<br>執筆・書き込み]
    P3 --> P4[Phase 4<br>履歴記録]
    P4 --> P5[Phase 5<br>レビュー]

Update workflow

The following workflow applies when updating an existing article with /article-writer.

Phase Purpose Operations
Phase 0 Load rules Read style/style_guide.md
Phase 1 Load existing article Read the target article and history file
Phase 2 Plan changes Identify affected sections, present proposed changes, obtain user approval
Phase 3 Edit and save Edit according to the style guide and apply changes after user approval
Phase 4 Append history Append changes and the rationale for decisions to the history file
Phase 5 Review Check consistency with references, user instructions, and history
flowchart LR
    P0[Phase 0<br>ルール読み込み] --> P1[Phase 1<br>既存記事読み込み]
    P1 --> P2[Phase 2<br>変更計画]
    P2 --> P3[Phase 3<br>編集・書き込み]
    P3 --> P4[Phase 4<br>履歴追記]
    P4 --> P5[Phase 5<br>レビュー]

Style guide

article-writer consults style/style_guide.md while writing. The file defines rules for maintaining article quality and consistency.

Main categories of rules

Category Rules
Headings Start at h2, avoid parentheses and colons in headings, leave a blank line after headings
Prose Use the polite Japanese desu/masu form consistently, end sentences with Japanese full stops, and provide English and katakana together when technical terms first appear
No colons Do not use half-width or full-width colons outside code blocks, except in URLs, times, and markup
Lists Use numbered lists for procedures and ordinary lists otherwise; avoid nested lists
Code blocks Require language tags and explanations before and after; avoid consecutive code blocks
Diagrams Include explanations before and after; do not end with a diagram alone
Tables and lists Prefer tables for parallel information

Example style guide

markdown
## 見出し

- h2から始める(h2 → h3)
- 見出しに括弧やコロンを含めない
- 見出しの後は1行空ける

## 文章

- 文体はです/ます調で統一する
- 句点(。)で文を終える
- 技術用語の初出時は英語とカタカナを併記する

Following the style guide keeps quality and tone consistent across articles.

Category templates

The categories/ directory contains templates organized by platform and category.

text
categories/
└── {platform}/           # プラットフォーム別ディレクトリ
    └── {category}.md     # カテゴリ別テンプレート(自動生成)

Each template defines a structure appropriate to its category. Running /generate-templates analyzes previous articles and automatically generates platforms and categories.

History management

article-writer automatically records article editing history. This helps maintain consistency by making earlier decisions available for reference.

Purpose of the history

  • Tracking decisions Records why a change was made and what criteria informed it.

  • Reference during updates Helps ensure that updates do not contradict earlier decisions.

  • Preserving references Records referenced URLs, related files, and user instructions.

History directory structure

History is stored in the history/{platform}/ directory. Articles and books are managed at different levels of granularity.

text
history/
└── {platform}/           # プラットフォーム別
    ├── {filename}.md     # 記事単位(記事形式)
    └── {book-name}/      # 本単位(本形式)
        └── *.md          # 章ごとの詳細履歴

Article versus book formats

Format Unit of management Examples
Article Individual article Zenn articles, Qiita articles
Book Individual book Zenn Book

For books, a history file for the whole book is maintained separately from detailed chapter histories.

What the history records

History files record the following information.

  • Metadata Target article path, platform, creation date, and last updated date.

  • Article objectives and approach Purpose, intended audience, and writing approach.

  • Edit history Date and time, summary of changes, decision rationale, user instructions, and references.

Platform support

Qiita and Zenn use different markup for message boxes and code blocks. article-writer identifies the platform during writing and uses the appropriate syntax.

Refer to the official documentation for each platform's markup.

  • Qiita Markdown syntax
  • Zenn Markdown syntax

The generate-templates Skill

/generate-templates analyzes existing articles and automatically generates article-writer's style/ and categories/ directories.

Pipeline phases

Phase Purpose Subagent Output
Phase 1 Parse directory path - Directory path
Phase 2 Extract patterns pattern-extractor JSON containing extracted patterns
Phase 3 User confirmation - Category classification approval
Phase 4 Generate or update Skill skill-writer style/, categories/
Phase 5 Completion report - Generation report
flowchart LR
    A[Phase 1<br>パス解析] --> B[Phase 2<br>pattern-extractor]
    B --> C[Phase 3<br>ユーザー確認]
    C --> D[Phase 4<br>skill-writer]
    D --> E[Phase 5<br>完了報告]

Phase 2 executes a command such as /pattern-extractor articles/. The pattern-extractor Subagent loads hundreds or thousands of articles in its independent context, extracts patterns, and returns them as JSON.

Phase 4 executes /skill-writer '{json}'. The skill-writer Subagent generates or updates style/ and categories/ from that JSON in its independent context.

Example usage

text
/generate-templates articles/

This one Skill automatically generates style/ and categories/. It requests user confirmation during the process, allowing the category classifications to be checked before generating the Skill.

Update mode

When files already exist, the Skill operates in update mode.

  • Read existing files.
  • Append new rules and patterns to the end of existing content.
  • Do not add duplicate rules.
  • Do not delete existing rules.

Setup

flowchart LR
    S1[Step 1<br>テンプレート<br>クローン] --> S2[Step 2<br>既存記事<br>収集]
    S2 --> S3[Step 3<br>スタイル<br>ファイル生成]
    S3 --> S4[Step 4<br>intro_outro<br>カスタマイズ]
    S4 --> S5[Step 5<br>動作確認]

Step 1: Clone the template

Copy the complete template from GitHub.

Copy the .claude directory into the project root. Its directory structure is as follows.

text
.claude/
├── commands/
│   ├── pattern-extractor.md
│   └── skill-writer.md
├── skills/
│   ├── article-writer/
│   │   ├── SKILL.md
│   │   ├── templates/
│   │   │   ├── style_guide.md
│   │   │   ├── intro_outro.md
│   │   │   ├── history_template.md
│   │   │   └── history_template_book.md
│   │   ├── style/
│   │   │   └── style_guide.md
│   │   ├── history/
│   │   │   └── {platform}/
│   │   └── categories/
│   │       └── {platform}/
│   └── generate-templates/
│       ├── SKILL.md
│       └── templates/
│           ├── format_rules.md
│           ├── wordings.md
│           ├── intro_outro.md
│           └── category.md
└── agents/
    ├── pattern-extractor.md
    └── skill-writer.md

All agent files (.claude/agents/*.md) require the following frontmatter setting.

yaml
permissionMode: bypassPermissions

Without this setting, the agents cannot perform file operations and Skill generation fails.

Step 2: Collect existing articles

Collect your articles as Markdown files. The directory structure is flexible, but organizing them by platform makes management easier.

text
articles/
└── {platform}/    # プラットフォーム別
    └── *.md       # 記事ファイル

Zenn offers an official export feature.

https://zenn.dev/settings/export

Step 3: Generate style files

Run /generate-templates to automatically generate style/ and categories/.

text
/generate-templates articles/

The following files are generated automatically.

text
.claude/skills/article-writer/
├── style/
│   └── style_guide.md    # スタイルガイド
└── categories/
    └── {platform}/       # プラットフォーム別(自動生成)
        └── {category}.md # カテゴリ別テンプレート

Step 4: Customize style_guide.md

Edit style/style_guide.md to add or modify rules that suit your writing style. You can customize heading usage, prose tone, code block conventions, and more.

Step 5: Test the Skill

Run /article-writer to verify that the generated Skill works correctly.

text
/article-writer 〇〇について簡単な記事を書いてください

Check the following.

  • Whether the rules in style/style_guide.md are applied.
  • Whether headings, prose, and lists follow the guide.
  • Whether the correct templates from categories/ are selected.

Usage and examples

Create a new article

text
/article-writer EASについて記事を書いてください。ドキュメントはこちらです。

https://docs.attest.org/

/article-writer performs the following steps.

  1. Phase 0 reads style/style_guide.md.
  2. Phase 1 gathers information using WebSearch.
  3. Phase 2 determines the category, designs the outline, and obtains user approval.
  4. Phase 3 writes and saves the article according to the style guide.
  5. Phase 4 creates the history file.
  6. Phase 5 checks that references and user instructions have been incorporated.

Update an existing article

text
/article-writer articles/react-hooks.md の「useEffect」セクションを最新情報に更新してください

The Skill detects the file path and switches to the update workflow.

Update style files

When new articles have been added, rerun /generate-templates to update style/ and categories/.

text
/generate-templates articles/

In update mode, existing content is retained and only new material is added.

Conclusion

This article covered automating article generation by analyzing previous articles with Claude Code. I also publish articles elsewhere if you would like to explore more of my work.