textkit

Guide building and debugging TextKit 2 text editors with NSTextLayoutManager.

4|1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill textkit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: textkit
Source: https://github.com/AutisticAF/claude-code-apple-dev-plugin/tree/main/skills/textkit
Command: npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill textkit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TextKit 2 introduces a viewport-based, composable text layout system that scales to large documents but exposes rough edges, platform inconsistencies, and missing glyph-level APIs; this Skill helps designers and engineers reason about the API, diagnose behavior, and implement robust custom text views and editors.

Core Features & Use Cases

  • Viewport-based layout: patterns for using NSTextLayoutManager, NSTextViewportLayoutController, and NSTextContentStorage to efficiently layout and render only visible text.
  • Custom rendering and annotations: guidance for subclassing NSTextLayoutFragment and integrating fragment views for line numbers, highlights, and overlays.
  • Editing concerns and workarounds: practical fixes for selection reset, extra fragment filtering, IME edge cases, multi-cursor replacement, and when to fall back to CoreText for glyph-level needs.
  • Migration guidance: side-by-side mappings from TextKit 1 to TextKit 2 and decision criteria for when to migrate or mix approaches.
  • Production reference: lessons and plugin patterns drawn from STTextView for building extensible, maintainable editors.

Quick Start

Ask for a step-by-step plan to implement a custom TextKit 2 editor with line numbers, syntax highlighting, multi-cursor support, and selection workarounds.

Frequently Asked Questions about textkit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate from TextKit 1 to TextKit 2 for a custom text editor?

Migrating from TextKit 1 to TextKit 2 involves adopting viewport-based layout with NSTextLayoutManager and NSTextContentStorage, replacing older layout managers. Side-by-side mappings and decision criteria help determine when to fully migrate or mix approaches for complex editors.

How does NSTextLayoutManager handle viewport-based layout for large documents?

NSTextLayoutManager, paired with NSTextViewportLayoutController and NSTextContentStorage, handles viewport-based layout by efficiently rendering only the visible text. This composable layout system scales to large documents while maintaining performance.

Why does my TextKit 2 selection reset after editing operations?

Selection resets in TextKit 2 stem from viewport-based layout edge cases and IME interactions. Practical workarounds include explicit selection management fixes and filtering extra fragments to maintain stable cursor positions during editing.

When should I fall back to CoreText instead of using TextKit 2?

You should fall back to CoreText when you need glyph-level access, as TextKit 2 lacks these APIs. CoreText provides the necessary low-level control for advanced text rendering scenarios not covered by NSTextLayoutFragment.

Can I implement multi-cursor editing using NSTextLayoutManager?

Yes, multi-cursor editing can be implemented using NSTextLayoutManager, though it requires specific replacement strategies. Production reference patterns drawn from STTextView provide guidance for building extensible, maintainable multi-cursor editors.