cg-extract-types

Extracts scattered structs and generic Result envelopes into centralized types.go files.

Updated May 16, 2026
One-click install
npx skills add https://github.com/alimtvnetwork/img-pdf-v2 --skill cg-extract-types-alimtvnetwork
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cg-extract-types
Source: https://github.com/alimtvnetwork/img-pdf-v2/tree/main/.agents/skills/cg-extract-types
Command: npx skills add https://github.com/alimtvnetwork/img-pdf-v2 --skill cg-extract-types-alimtvnetwork

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate ad-hoc unexported structs and repeated raw generic instantiations (ResultSlice[T], ResultMap[K, V], Wrap[T]) scattered across implementation files, making types hard to reuse, audit, and maintain consistently. ## Core Features & Use Cases - Autonomous Type Auditing: Uses ripgrep and fast Python discovery scripts to inventory unexported domain structs and raw generic returns across the codebase, building a grouped violation ledger. - Centralized Type Extraction: Moves domain models into dedicated types.go files with exported PascalCase names and creates single reusable type aliases for repeated generic Result envelopes. - Naming & Safety Enforcement: Applies affirmative boolean field naming (isDefined, hasRecords), pointer-safe fluent predicates, and clean package boundaries with zero dependency cycles. - Use Case: A Go service has scheduleExportBundle structs declared inline in importer.go and ResultSlice[...] repeated in five files. This Skill extracts them into schedule/types.go with canonical aliases and refactors all call sites. ## Quick Start Audit this repository for inline structs and raw generic Result types, then extract them into dedicated types.go files with reusable named aliases.

Frequently Asked Questions about cg-extract-types

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

FAQPage Schema
How do I centralize scattered struct definitions in a Go codebase?

Audit implementation files for unexported inline structs using ripgrep patterns, then extract them into a dedicated types.go file per package as exported PascalCase types. Refactor sibling files to consume the single named type instead of redeclaring structs.

When should I create a type alias for a generic Result type?

Create a canonical type alias in types.go when a generic type is used three or more times with the same type argument, or when it wraps a domain payload struct. This eliminates repeated raw instantiations like ResultSlice[ScheduleExportBundle] across files.

Does this type extraction approach work for TypeScript or Rust?

Yes, the same pattern applies polyglot: TypeScript uses src/<module>/types.ts with exported interfaces and type aliases, Rust uses <module>/types.rs with pub structs and pub type aliases, and C# uses Types.cs with records.

What boolean field naming conventions does this enforce?

All boolean fields must carry affirmative prefixes like isDefined, hasRecords, isStopped, or isEnabled. Bare names like defined or stop are banned, and inverted checks like !isEmpty must be replaced with affirmative predicates like IsDefined().

What are the limitations of this refactoring workflow?

The workflow forbids running tests, builds, or full CI/CD pipelines during execution, relying only on targeted file-level linters for verification. It also prohibits version bumps, releases, and per-file commits, requiring one atomic commit at the end.