1
---
2
name: issue-fields-migration
3
description: 'Bulk-migrate metadata to GitHub issue fields from two sources: repo labels (e.g. priority labels to a Priority field) and Project V2 fields. Use when users say "migrate my labels to issue fields", "migrate project fields to issue fields", "convert labels to issue fields", "copy project field values to issue fields", or ask about adopting issue fields. Issue fields are org-level typed metadata (single select, text, number, date) that replace label-based workarounds with structured, searchable, cross-repo fields.'
4
---
5
6
# Issue Fields Migration
7
8
[Issue fields](https://github.blog/changelog/2026-03-12-issue-fields-structured-issue-metadata-is-in-public-preview/) are org-level typed metadata (single select, text, number, date) that replace label-based workarounds with structured, searchable, cross-repo fields. Every organization gets `Priority`, `Effort`, `Start date`, and `Target date` preconfigured, with support for up to 25 custom fields.
9
10
This skill bulk-migrates existing metadata into issue fields from two sources:
11
12
- **Repo labels**: Convert labels like `p0`, `p1`, `priority/high` into structured issue field values (e.g. the Priority field). Supports migrating multiple labels at once and optionally removing them after migration.
13
- **Project V2 fields**: Copy field values (single select, text, number, date, iteration) from a GitHub Project into the equivalent org-level issue fields.
14
15
## When to Use
16
17
- User added org-level issue fields that overlap with existing project fields
18
- User wants to copy values from project fields to issue fields before deleting the old project fields
19
- User asks about "migrating", "transferring", or "copying" project field data to issue fields
20
- User wants to convert repo labels (e.g., p0, p1, p2, p3) into issue field values (e.g., Priority field)
21
- User asks about replacing labels with issue fields or cleaning up labels after adopting issue fields
22
23
## Prerequisites
24
25
- The target org must have issue fields enabled
26
- The issue fields must already exist at the org level
27
- For project field migration: issue fields must be added to the project
28
- For label migration: labels must exist on the target repo(s)
29
- The user must have write access to the repos (and project, if migrating project fields)
30
- `gh` CLI must be authenticated with appropriate scopes
31
32
## Available Tools
33
34
### MCP Tools (read operations)
35
36
| Tool | Purpose |
37
|------|---------|
38
| `mcp__github__projects_list` | List project fields (`list_project_fields`), list project items with values (`list_project_items`) |
39
| `mcp__github__projects_get` | Get details of a specific project field or item |
40
41
### CLI / REST API
42
43
| Operation | Command |
44
|-----------|---------|
45
| List org issue fields | `gh api /orgs/{org}/issue-fields -H "X-GitHub-Api-Version: 2026-03-10"` |
46
| Read issue field values | `gh api /repos/{owner}/{repo}/issues/{number}/issue-field-values -H "X-GitHub-Api-Version: 2026-03-10"` |
47
| Write issue field values | `gh api /repositories/{repo_id}/issues/{number}/issue-field-values -X POST -H "X-GitHub-Api-Version: 2026-03-10" --input -` |
48
| Get repository ID | `gh api /repos/{owner}/{repo} --jq .id` |
49
| List repo labels | `gh label list -R {owner}/{repo} --limit 1000 --json name,color,description` |
50
| List issues by label | `gh issue list -R {owner}/{repo} --label "{name}" --state all --json number,title,labels --limit 1000` |
51
| Remove label from issue | `gh api /repos/{owner}/{repo}/issues/{number}/labels/{label_name} -X DELETE` |
52
53
See [references/issue-fields-api.md](references/issue-fields-api.md), [references/projects-api.md](references/projects-api.md), and [references/labels-api.md](references/labels-api.md) for full API details.
54
55
## Workflow
56
57
### Step 0: Migration Source
58
59
Ask the user what they are migrating:
60
61
1. **"Are you migrating labels or project fields?"**
62
- **Labels**: proceed to the [Label Migration Flow](#label-migration-flow) below.
63
- **Project fields**: proceed to the [Project Field Migration Flow](#project-field-migration-flow) below.
64
65
2. If the user says **labels**:
66
- Ask: "Which org and repo(s) contain the labels?"
67
- Ask: "Which labels do you want to migrate?" (they can name them or say "show me the labels first")
68
69
3. If the user says **project fields**:
70
- Ask: "Can you share the link to your project or tell me the org name and project number?"
71
- Ask: "Which field do you want to migrate?"
72
73
---
74
75
### Label Migration Flow
76
77
Use this flow when the user wants to convert repo labels into issue field values. Labels can only map to `single_select` issue fields (each label name maps to one option value).
78
79
#### Phase L1: Input & Label Discovery
80
81
1. Ask the user for: **org name** and **repo(s)** to migrate.
82
2. Fetch labels from each repo:
83
84
```bash
85
gh label list -R {owner}/{repo} --limit 1000 --json name,color,description
86
```
87
88
3. Fetch org issue fields:
89
90
```bash
91
gh api /orgs/{org}/issue-fields \
92
-H "X-GitHub-Api-Version: 2026-03-10" \
93
--jq '.[] | {id, name, content_type, options: [.options[]?.name]}'
94
```
95
96
4. **Filtering** (for repos with many labels): if the repo has 50+ labels, group by common prefix (e.g., `priority-*`, `team-*`, `type-*`) or color. Let the user filter with "show labels matching priority" or "show blue labels" before mapping. Never dump 100+ labels at once.
97
98
5. Ask the user which labels map to which issue field and option. Support these patterns:
99
- **Single label to single field**: e.g., label "bug" → Type field, "Bug" option
100
- **Multiple labels to one field** (bulk): e.g., labels p0, p1, p2, p3 → Priority field with matching options
101
- **Multiple labels to multiple fields**: e.g., p1 → Priority + frontend → Team. Handle as separate mapping groups.
102
103
6. **Auto-suggest mappings**: for each label, attempt to match issue field options using these patterns (in order):
104
- **Exact match** (case-insensitive): label `Bug` → option `Bug`
105
- **Prefix-number** (`{prefix}-{n}` → `{P}{n}`): label `priority-1` → option `P1`
106
- **Strip separators** (hyphens, underscores, spaces): label `good_first_issue` → option `Good First Issue`
107
- **Substring containment**: label `type: bug` → option `Bug`
108
109
Present all suggestions at once for the user to confirm, correct, or skip.
110
111
**Example output:**
112
113
```
114
Labels in github/my-repo (showing relevant ones):
115
p0, p1, p2, p3, bug, enhancement, frontend, backend
116
117
Org issue fields (single_select):
118
Priority: Critical, P0, P1, P2, P3
119
Type: Bug, Feature, Task
120
Team: Frontend, Backend, Design
121
122
Suggested mappings:
123
Label "p0" → Priority "P0"
124
Label "p1" → Priority "P1"
125
Label "p2" → Priority "P2"
126
Label "p3" → Priority "P3"
127
Label "bug" → Type "Bug"
128
Label "frontend" → Team "Frontend"
129
Label "backend" → Team "Backend"
130
Label "enhancement" → (no auto-match; skip or map manually)
131
132
Confirm, adjust, or add more mappings?
133
```
134
135
#### Phase L2: Conflict Detection
136
137
After finalizing the label-to-option mappings, check for conflicts. A conflict occurs when an issue has multiple labels that map to the **same** issue field (since single_select fields can hold only one value).
138
139
1. Group label mappings by target issue field.
140
2. For each field with multiple label sources, note the potential for conflicts.
141
3. Ask the user for a conflict resolution strategy:
142
- **First match**: use the first matching label found (by order of label mapping list)
143
- **Skip**: skip issues with conflicting labels and report them
144
- **Manual**: present each conflict for the user to decide
145
146
**Example:**
147
148
```
149
Potential conflict: labels "p0" and "p1" both map to the Priority field.
150
If an issue has both labels, which value should win?
151
152
Options:
153
1. First match (use "p0" since it appears first in the mapping)
154
2. Skip conflicting issues
155
3. I'll decide case by case
156
```
157
158
#### Phase L3: Pre-flight Checks & Data Scan
159
160
1. For each repo, verify write access and cache the `repository_id`:
161
162
```bash
163
gh api /repos/{owner}/{repo} --jq '{full_name, id, permissions: .permissions}'
164
```
165
166
2. For each label in the mapping, fetch matching issues:
167
168
```bash
169
gh issue list -R {owner}/{repo} --label "{label_name}" --state all \
170
--json number,title,labels,type --limit 1000
171
```
172
173
**Warning**: `--limit 1000` silently truncates results. If you expect a label may have more than 1000 issues, paginate manually or verify the total count first (e.g., `gh issue list --label "X" --state all --json number | jq length`).
174
175
**PR filtering**: `gh issue list` returns both issues and PRs. Include `type` in the `--json` output and filter for `type == "Issue"` if the user only wants issues migrated.
176
177
3. If **all selected labels return 0 issues**, stop and tell the user. Suggest: try different labels, check spelling, or try a different repository. Do not proceed with an empty migration.
178
179
4. For multi-repo migrations, repeat across all specified repos.
180
181
5. For each issue found:
182
- Check if the issue already has a value for the target issue field (skip if set).
183
- Detect multi-label conflicts (issue has two labels for the same field).
184
- Apply the conflict resolution strategy chosen in Phase L2.
185
- Classify: **migrate**, **skip (already set)**, **skip (conflict)**, or **skip (no matching label)**.
186
187
#### Phase L4: Preview / Dry-Run
188
189
Present a summary before any writes.
190
191
**Example preview:**
192
193
```
194
Label Migration Preview
195
196
Source: labels in github/my-repo
197
Target fields: Priority, Type, Team
198
199
| Category | Count |
200
|-------------------------|-------|
201
| Issues to migrate | 156 |
202
| Already set (skip) | 12 |
203
| Conflicting labels (skip)| 3 |
204
| Total issues with labels| 171 |
205
206
Label breakdown:
207
"p1" → Priority "P1": 42 issues
208
"p2" → Priority "P2": 67 issues
209
"p3" → Priority "P3": 38 issues
210
"bug" → Type "Bug": 9 issues
211
212
Sample changes (first 5):
213
github/my-repo#101: Priority → "P1"
214
github/my-repo#203: Priority → "P2", Type → "Bug"
215
github/my-repo#44: Priority → "P3"
216
github/my-repo#310: Priority → "P1"
217
github/my-repo#7: Type → "Bug"
218
219
After migration, do you also want to remove the migrated labels from issues? (optional)
220
221
Estimated time: ~24s (156 API calls at 0.15s each)
222
223
Proceed?
224
```
225
226
#### Phase L5: Execution
227
228
1. For each issue to migrate, write the issue field value (same endpoint as project field migration):
229
230
```bash
231
echo '{"issue_field_values": [{"field_id": FIELD_ID, "value": "OPTION_NAME"}]}' | \
232
gh api /repositories/{repo_id}/issues/{number}/issue-field-values \
233
-X POST \
234
-H "X-GitHub-Api-Version: 2026-03-10" \
235
--input -
236
```
237
238
Replace `FIELD_ID` with the integer field ID (e.g., `1`) and `OPTION_NAME` with the option name string.
239
240
2. If the user opted to remove labels, remove each migrated label after successful field write:
241
242
```bash
243
gh api /repos/{owner}/{repo}/issues/{number}/labels/{label_name} -X DELETE
244
```
245
246
URL-encode label names that contain spaces or special characters.
247
248
3. **Pacing**: 100ms delay between calls. Exponential backoff on HTTP 429 (1s, 2s, 4s, up to 30s).
249
4. **Progress**: report every 25 items (e.g., "Migrated 75/156 issues...").
250
5. **Error handling**: log failures but continue. Include label removal failures separately.
251
6. **Final summary**:
252
253
```
254
Label Migration Complete
255
256
| Result | Count |
257
|-----------------------|-------|
258
| Fields set | 153 |
259
| Labels removed | 153 |
260
| Skipped | 15 |
261
| Failed (field write) | 2 |
262
| Failed (label remove) | 1 |
263
264
Failed items:
265
github/my-repo#501: 403 Forbidden (insufficient permissions)
266
github/my-repo#88: 422 Validation failed (field not available on repo)
267
github/my-repo#120: label removal failed (404, label already removed)
268
```
269
270
---
271
272
### Project Field Migration Flow
273
274
Use this flow when the user wants to copy values from a GitHub Project V2 field to the corresponding org-level issue field.
275
276
Follow these six phases in order. Always preview before executing.
277
278
#### Phase P1: Input & Discovery
279
280
1. Ask the user for: **org name** and **project number** (or project URL).
281
2. Fetch project fields:
282
283
```bash
284
# Use MCP tool
285
mcp__github__projects_list(owner: "{org}", project_number: {n}, method: "list_project_fields")
286
```
287
288
3. Fetch org issue fields:
289
290
```bash
291
gh api /orgs/{org}/issue-fields \
292
-H "X-GitHub-Api-Version: 2026-03-10" \
293
--jq '.[] | {id, name, content_type, options: [.options[]?.name]}'
294
```
295
296
4. **Filter out proxy fields**: after issue fields are enabled on a project, some project fields appear as "proxy" entries with empty `options: []` for single-select types. These mirror the real issue fields and should be ignored. Only match against project fields that have actual option values.
297
298
5. Auto-match fields by name (case-insensitive) with compatible types:
299
300
| Project Field Type | Issue Field Type | Compatible? |
301
|-------------------|-----------------|-------------|
302
| TEXT | text | Yes, direct copy |
303
| SINGLE_SELECT | single_select | Yes, option mapping needed |
304
| NUMBER | number | Yes, direct copy |
305
| DATE | date | Yes, direct copy |
306
| ITERATION | (none) | No equivalent; skip with warning |
307
308
6. Present the proposed field mappings as a table. Let the user confirm, adjust, or skip fields.
309
310
**Example output:**
311
312
```
313
Found 3 potential field mappings:
314
315
| # | Project Field | Type | Issue Field | Status |
316
|---|-------------------|---------------|--------------------|------------|
317
| 1 | Priority (renamed) | SINGLE_SELECT | Priority | Auto-match |
318
| 2 | Due Date | DATE | Due Date | Auto-match |
319
| 3 | Sprint | ITERATION | (no equivalent) | Skipped |
320
321
Proceed with fields 1 and 2? You can also add manual mappings.
322
```
323
324
#### Phase P2: Option Mapping (single-select fields only)
325
326
For each matched single-select pair:
327
328
1. Compare option names between the project field and issue field (case-insensitive).
329
2. Auto-match options with identical names.
330
3. For any unmapped project field options, present **all** unmapped options in a single summary and ask the user to provide mappings for all of them at once. Do not prompt one-by-one; batch them into a single exchange.
331
4. Show the final option mapping table for confirmation.
332
333
**Example output:**
334
335
```
336
Option mapping for "Release - Target":
337
338
Auto-matched (case-insensitive):
339
"GA" → "GA"
340
"Private Preview" → "Private Preview"
341
"Public Preview" → "Public Preview"
342
343
Unmapped project options (need your input):
344
1. "Internal Only" → which issue field option? (or skip)
345
2. "Retired" → which issue field option? (or skip)
346
3. "Beta" → which issue field option? (or skip)
347
4. "Deprecated" → which issue field option? (or skip)
348
349
Available issue field options not yet mapped: "Internal", "Sunset", "Beta Testing", "End of Life"
350
351
Please provide mappings for all 4 options above (e.g., "1→Internal, 2→Sunset, 3→Beta Testing, 4→skip").
352
```
353
354
#### Phase P3: Pre-flight Checks
355
356
Before scanning items, verify write access to each repository that may be touched:
357
358
1. From the project items (first page), collect the unique set of `{owner}/{repo}` values.
359
2. For each unique repo, verify the authenticated user has Issues write permission:
360
361
```bash
362
gh api /repos/{owner}/{repo} --jq '{full_name, permissions: .permissions}'
363
```
364
365
3. If any repo shows `push: false` or `triage: false`, warn the user before proceeding. Items in those repos will fail at write time.
366
4. Cache the `repository_id` (integer) for each repo now; you will need it in Phase 6:
367
368
```bash
369
gh api /repos/{owner}/{repo} --jq .id
370
```
371
372
#### Phase P4: Data Scan
373
374
1. Fetch all project items using MCP. **Important**: for projects with more than ~200 items, `gh api graphql --paginate` is unreliable (it concatenates JSON responses without proper separators and can time out). Use the MCP tool which handles pagination internally, or use explicit cursor-based pagination:
375
376
```bash
377
# Preferred: use MCP tool (handles pagination automatically)
378
mcp__github__projects_list(owner: "{org}", project_number: {n}, method: "list_project_items")
379
380
# Fallback for large projects: manual cursor-based pagination
381
# Fetch 100 items per page, advancing the cursor each time.
382
# Process each page before fetching the next to avoid memory issues.
383
# Save progress (page number or last cursor) so you can resume if interrupted.
384
```
385
386
2. For each item:
387
- Skip if it is a draft item (not a real issue).
388
- Extract the source project field value.
389
- Skip if the source value is empty.
390
- Check if the issue already has a value for the target issue field:
391
392
```bash
393
gh api /repos/{owner}/{repo}/issues/{number}/issue-field-values \
394
-H "X-GitHub-Api-Version: 2026-03-10"
395
```
396
397
- If the issue field already has a value, skip it (preserve existing data).
398
399
3. Classify each item into one of:
400
- **Migrate**: has source value, no existing target value
401
- **Skip (already set)**: target issue field already has a value
402
- **Skip (no source)**: project field is empty for this item
403
- **Skip (draft)**: item is a draft, not a real issue
404
- **Skip (unmapped option)**: single-select value was not mapped
405
406
#### Phase P5: Preview / Dry-Run
407
408
Present a summary before any writes.
409
410
**If user requested dry-run**: show the full detailed report (every issue, its current value, proposed new value, and skip reason) and stop. Do not execute.
411
412
**Otherwise (preview mode)**: show summary counts and a sample of changes, then ask for confirmation.
413
414
**Example preview:**
415
416
```
417
Migration Preview for Project #42
418
419
Fields to migrate: Priority, Due Date
420
421
| Category | Count |
422
|------------------------|-------|
423
| Items to migrate | 847 |
424
| Already set (skip) | 23 |
425
| No source value (skip) | 130 |
426
| Draft items (skip) | 12 |
427
| Total project items | 1,012 |
428
429
Sample changes (first 5):
430
github/repo-a#101: Priority → "High"
431
github/repo-a#203: Priority → "Medium", Due Date → "2025-03-15"
432
github/repo-b#44: Priority → "Low"
433
github/repo-a#310: Due Date → "2025-04-01"
434
github/repo-c#7: Priority → "Critical"
435
436
Estimated time: ~127s (847 API calls at 0.15s each)
437
438
Proceed with migration? This will update 847 issues across 3 repositories.
439
```
440
441
#### Phase P6: Execution
442
443
1. Use the `repository_id` values cached in Phase 3.
444
445
2. For each item to migrate, write the issue field value:
446
447
```bash
448
echo '{"issue_field_values": [{"field_id": FIELD_ID, "value": "VALUE"}]}' | \
449
gh api /repositories/{repo_id}/issues/{number}/issue-field-values \
450
-X POST \
451
-H "X-GitHub-Api-Version: 2026-03-10" \
452
--input -
453
```
454
455
Replace `FIELD_ID` with the integer field ID (e.g., `1`) and `VALUE` with the value string.
456
457
3. **Pacing**: add a 100ms delay between API calls. On HTTP 429 responses, use exponential backoff (1s, 2s, 4s, up to 30s).
458
4. **Progress**: report status every 25 items (e.g., "Migrated 75/847 items...").
459
5. **Error handling**: log failures but continue processing remaining items.
460
6. **Final summary**:
461
462
```
463
Migration Complete
464
465
| Result | Count |
466
|---------|-------|
467
| Success | 842 |
468
| Skipped | 165 |
469
| Failed | 5 |
470
471
Failed items:
472
github/repo-a#501: 403 Forbidden (insufficient permissions)
473
github/repo-b#88: 422 Validation failed (field not available on repo)
474
...
475
```
476
477
## Important Notes
478
479
- **Write endpoint quirk**: the REST API for writing issue field values uses `repository_id` (integer), not `owner/repo`. Always look up the repo ID first with `gh api /repos/{owner}/{repo} --jq .id`.
480
- **Single-select values**: the REST API accepts option **names** as strings (not option IDs). This makes mapping straightforward for both project fields and labels.
481
- **Reading values back**: when reading issue field values from the API response, use `.single_select_option.name` for the human-readable value. The `.value` property returns the internal option ID (an integer like `1201`), not the display name.
482
- **API version header**: all issue fields endpoints require `X-GitHub-Api-Version: 2026-03-10`.
483
- **Cross-repo items**: a project can contain issues from multiple repositories. Cache the repo ID per-repository to avoid redundant lookups.
484
- **Preserve existing values**: never overwrite an issue field value that is already set. Skip those items.
485
- **Iteration fields**: have no issue field equivalent. Always warn the user and skip.
486
- **Draft items**: project items that are not linked to real issues cannot have issue field values. Skip with a note.
487
- **Labels are repo-scoped**: unlike project fields, labels exist per-repo. The same label name may exist in multiple repos; migration applies separately to each.
488
- **Label conflicts**: an issue can have multiple labels that map to the same single_select field. Always detect and resolve these before execution.
489
- **Label removal is optional**: after migration, the user may want to keep labels as backup or remove them. Always ask before removing.
490
- **URL-encode label names**: labels with spaces or special characters must be URL-encoded when used in REST API paths (e.g., `good%20first%20issue`).
491
- **Script generation for scale**: for migrations of 100+ issues, generate a standalone shell script rather than executing API calls one at a time through the agent. This is faster, resumable, and avoids agent timeout issues.
492
- **Idempotent migrations**: re-running a migration is safe. Issues that already have the target field value set will be skipped. This means you can safely resume a partial migration without duplicating work.
493
- **`--limit 1000` truncation**: `gh issue list --limit 1000` silently stops at 1000 results. For labels with more issues, paginate with `--jq` and cursor-based pagination or run multiple filtered queries (e.g., by date range).
494
- **macOS bash version**: macOS ships with bash 3.x, which does not support `declare -A` (associative arrays). Generated scripts should use POSIX-compatible constructs or note the incompatibility and suggest `brew install bash`.
495
- **Issues vs PRs**: `gh issue list` returns both issues and pull requests. If the migration should only target issues, include `type` in `--json` output and filter for `type == "Issue"`.
496
497
## Examples
498
499
### Example 1: Full Migration
500
501
**User**: "I need to migrate Priority values from our project to the new org Priority issue field"
502
503
**Action**: Follow Phases P1-P6. Discover fields, map options, check permissions, scan items, preview, execute.
504
505
### Example 2: Dry-Run Only
506
507
**User**: "Show me what would happen if I migrated fields from project #42, but don't actually do it"
508
509
**Action**: Follow Phases P1-P5 only. Present the full dry-run report with every item listed. Do not execute.
510
511
### Example 3: Multiple Fields
512
513
**User**: "Migrate Priority and Due Date from project #15 to issue fields"
514
515
**Action**: Same workflow, but process both fields in a single pass. During the data scan, collect values for all mapped fields per item. Write all field values in a single API call per issue.
516
517
### Example 4: Single Label to Issue Field
518
519
**User**: "I want to migrate the 'bug' label to the Type issue field"
520
521
**Action**: Route to Label Migration Flow. Ask for org/repo, list labels, confirm mapping: label "bug" → Type field "Bug" option. Scan issues with that label, preview, execute. Ask whether to remove the label after migration.
522
523
### Example 5: Multiple Labels to One Field (Bulk)
524
525
**User**: "We have p0, p1, p2, p3 labels and want to convert them to the Priority issue field"
526
527
**Action**: Route to Label Migration Flow. Map all four labels to Priority field options (p0→P0, p1→P1, p2→P2, p3→P3). Check for conflicts (issues with multiple priority labels). Preview all changes in one summary. Execute in one pass. Optionally remove all four labels from migrated issues.
528
529
### Example 6: Cross-Repo Label Migration with Label Removal
530
531
**User**: "Migrate the 'frontend' and 'backend' labels to the Team issue field across github/issues, github/memex, and github/mobile, then remove the old labels"
532
533
**Action**: Route to Label Migration Flow. Confirm repos and label mappings: "frontend"→Team "Frontend", "backend"→Team "Backend". Scan all three repos for issues with these labels. Detect conflicts (issues with both labels). Preview across repos. Execute field writes, then remove labels from migrated issues. Report per-repo stats.
534