typescript-import-audit
Fungsinya
Skill ini menjelaskan tinjauan empat langkah terhadap kode TypeScript untuk mencari impor yang berantakan, impor ganda, induk kelas yang hilang, dan ekspor yang belum ada. Skill ini ditujukan untuk pengembang yang sedang merapikan proyek TypeScript.
Kapan dipakai
- βSaat Anda ingin membersihkan impor di proyek TypeScript.
- βSaat sebuah kelas seharusnya memperluas kelas dasar tetapi tidak melakukannya.
- βSaat file barrel tidak memiliki ekspor yang dibutuhkan file lain.
Link skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-import-audit/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda memeriksa impor TypeScript saya dan memperbaiki impor ganda atau ekspor yang hilang?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent membaca file yang relevan, mencari empat jenis masalah, dan menerapkan perbaikan kecil yang tepat untuk setiap masalah.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
TypeScript Import & Structure Audit
A step-by-step workflow for auditing TypeScript projects for common structural and import hygiene problems, then applying targeted fixes.
Overview
This skill covers four audit checks and their corresponding fixes:
| # | Issue | Fix |
|---|---|---|
| 1 | Value imports used only as type annotations | Split with import type |
| 2 | Duplicate imports from the same module | Consolidate into one import statement |
| 3 | Classes missing expected base class extension | Add extends BaseClass |
| 4 | Missing re-exports in barrel (index.ts) files |
Add the missing export lines |
Step 1 β Read All Relevant Files in Parallel
Before making any changes, read all files that need to be audited in a single parallel batch. This avoids slow sequential reads.
Read in parallel:
- src/index.ts (barrel file)
- src/**/*.ts (all source files)
- Any explicitly named files from the task spec
Look for:
- All
importstatements at the top of each file - Class declarations (
class Foo) - Export lists in barrel files
Step 2 β Audit Check 1: Value Imports Used Only as Types
Detection
For every import { A, B } from 'module' statement, check whether each
imported name is used only in type positions (: TypeName, as TypeName,
<TypeName> generics, implements TypeName). If a name never appears in a
value position (instantiation, function call, assignment), it should be a
type-only import.
// β Bad β Foo is only used as a type annotation
import { Foo, bar } from './module';
const x: Foo = bar();
// β
Good β split into value import + type import
import { bar } from './module';
import type { Foo } from './module';
Fix Pattern
- Identify all names in the import that are type-only.
- Remove them from the value import (delete the value import entirely if all names are type-only).
- Add (or merge into an existing)
import type { ... } from 'module'statement.
Step 3 β Audit Check 2: Duplicate Imports from the Same Module
Detection
Scan for two or more import statements that reference the same module path:
// β Bad β two imports from the same source
import { ComponentA } from './components';
import { ComponentB } from './components';
Fix Pattern
Merge all named imports from the same module into a single statement:
// β
Good
import { ComponentA, ComponentB } from './components';
If there is a mix of value and type imports from the same module, keep them as two separate lines (import { ... } and import type { ... }), but ensure there is at most one of each kind per module path.
Step 4 β Audit Check 3: Classes That Should Extend a Base Class
Detection
Look for class declarations that:
- Implement an interface that implies a base class, OR
- Are described in comments / documentation as extending something, OR
- Contain methods/properties that are defined on a known base class
// β Missing base class
class MyPanel implements PanelInterface {
render() { ... }
}
// β
Correct
class MyPanel extends BasePanel implements PanelInterface {
render() { ... }
}
Fix Pattern
Add extends BaseClass between the class name and any implements clause:
class ClassName extends BaseClass implements InterfaceName { ... }
Ensure the base class is imported if it is not already.
Step 5 β Audit Check 4: Missing Re-exports in Barrel Files
Detection
A barrel file (index.ts) should re-export everything that is part of the
public API. Common gaps:
- A new file was added but never added to
index.ts - A named export inside a file is not forwarded by the barrel
// src/components/MyWidget.ts
export class MyWidget { ... }
export type MyWidgetProps = { ... }
// src/components/index.ts β β missing MyWidget
export { SomeOtherThing } from './SomeOtherThing';
Fix Pattern
Add the missing re-export line:
// src/components/index.ts β β
fixed
export { SomeOtherThing } from './SomeOtherThing';
export { MyWidget } from './MyWidget';
export type { MyWidgetProps } from './MyWidget';
Use export type { ... } for type-only exports to maintain strict type/value separation.
Step 6 β Apply Fixes and Verify
Order of operations
- Fix duplicate imports first (consolidation may surface type-only candidates).
- Fix **value vs. type im
Pertanyaan umum
Apa itu file barrel?
Itu adalah file indeks yang mengumpulkan ekspor dari beberapa file agar dapat diimpor dari satu tempat.
Apa arti impor khusus tipe?
Itu adalah impor yang hanya dipakai untuk label tipe, sehingga dapat ditandai agar tidak dimuat saat dijalankan.
Apakah audit mengubah file secara otomatis?
Skill ini membaca file terlebih dahulu lalu menerapkan perbaikan, sehingga Anda dapat meninjau perubahan yang dibuat.
Detail
Deskripsi asli dari pembuat
Systematic workflow for auditing TypeScript codebases for import hygiene issues (value vs. type imports, duplicates), missing base class extensions, and incomplete barrel file re-exports, with actionable fix patterns.
repo: HKUDS/AgentPilot
Popularitas
- Bintang GitHub
- 7.8k
- Peringkat
- #13085
- Lisensi
- MIT
- Diperbarui
- 1/11/2026
Komentar
- β¦
Skill lain dari repositori ini
agentpilot
7.8kMembantu agent Anda meningkatkan proyek langkah demi langkah dengan menyiapkan tugas dan menjalankan loop AgentPilot yang mengusulkan, menguji, dan memberi skor pada perubahan.
openspace
7.8kMembantu agent Anda menyiapkan OpenSpace, alat yang menyimpan dan mengambil skill agent, lalu menghubungkannya ke aplikasi AI Anda melalui MCP.
rsi-arena
7.8kMembantu agent Anda menyiapkan dan menjalankan tes benchmark AI standar, seperti AIME dan Terminal-Bench, untuk membandingkan berbagai metode perbaikan.
experiment-guide
7.8kMembantu agent Anda merencanakan eksperimen kecil, membaca hasilnya, dan mencatat temuan saat menyelidiki cara memperbaiki sebuah program.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.