원클릭으로
community-json-pr-hygiene
Submit PRs to upstream community JSON registries without mangling formatting or diff hygiene
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Submit PRs to upstream community JSON registries without mangling formatting or diff hygiene
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Pattern for keeping a rolling temperature-trend sample buffer in Hubitat state, computing slope over a configurable window, and classifying rising/falling/steady/unknown.
Implement Tuya Local v3.3 Groovy drivers on Hubitat using rawSocket, AES-128-ECB, queued retries, and defensive frame parsing.
Use Hubitat async HTTP plus a request queue to authenticate with Cognito, cache tokens in state, refresh proactively, and replay a single 401-failed request.
When two agents produce overlapping skills in one session, consolidate by merging unique content into the highest-confidence existing skill.
Never let cached-state dedup bypass session validity in cloud-backed Hubitat drivers.
Standard guard pattern for async HTTP response callbacks in Hubitat drivers
| name | community-json-pr-hygiene |
| description | Submit PRs to upstream community JSON registries without mangling formatting or diff hygiene |
| domain | pr-submission, json-editing, community-contrib |
| confidence | low |
| source | observed |
| tools | null |
When submitting a PR that edits a JSON file maintained by an upstream community (HPM repositories.json, npm registry index, GitHub Awesome lists in JSON form, public settings files), the formatting of the source file matters. The maintainers expect diffs to show only the intended changes — not hundreds of lines of reformatting.
Example failure mode: PR #106 to HubitatCommunity/hubitat-packagerepositories. The target repositories.json uses tab indentation. Using PowerShell's ConvertFrom-Json | ConvertTo-Json round-trip to edit it reformatted the entire file to spaces, resulting in a diff showing nearly every line changed when the intent was to add a single entry.
# ❌ DO NOT DO THIS (will reformat the file)
$json = ConvertFrom-Json (Get-Content repositories.json -Raw)
# ... edit $json ...
$json | ConvertTo-Json -Depth 100 | Set-Content repositories.json
# ✅ DO THIS (preserves exact formatting)
$content = Get-Content repositories.json -Raw
# ... use regex or string search to locate insertion point ...
$newContent = $content -replace 'search-pattern', 'replacement-text'
Set-Content -Path repositories.json -Value $newContent -NoNewline
# Example: find the last entry in a JSON array and insert before the closing bracket
$pattern = '(\s+}\s*\])' # Match last object's closing brace and array close
$replacement = @"
},
{
"name": "My New Entry",
"url": "https://..."
}
]
"@
$newContent = $content -replace $pattern, $replacement
# After editing, **always** check the diff to ensure only intended lines changed
git diff repositories.json
# Should show only the 3-5 lines you added, not the entire file reformatted
When writing the edited content back, preserve:
git diff --no-index or tail -c to confirm# ConvertFrom-Json / ConvertTo-Json ALWAYS reformat:
# - Spaces instead of tabs
# - Default depth of 2 (arrays of objects truncate to string)
# - Keys reordered (no guarantee of order preservation)
# - Blank lines removed
# - Trailing newlines stripped
$json = ConvertFrom-Json (Get-Content file.json -Raw)
# Even with -Depth 100, the above problems still occur
$json | ConvertTo-Json -Depth 100 | Set-Content file.json
# Same problem in Python: reformats the file
import json
with open('repositories.json', 'r') as f:
data = json.load(f)
# ... edit data ...
with open('repositories.json', 'w') as f:
json.dump(data, f, indent=2) # Reformat reintroduced!
// Same issue — JSON.stringify() reformats
const data = JSON.parse(fs.readFileSync('file.json', 'utf8'));
// ... edit ...
fs.writeFileSync('file.json', JSON.stringify(data, null, 2)); // Reformatted!
ConvertTo-Json defaults to depth 2 — even if you specify -Depth 100, the formatting changes occur (indentation, key order, blank lines).
Test the round-trip locally — before committing to an external repo, always:
git add repositories.json
git diff --cached repositories.json
If the diff shows hundreds of lines, STOP and revert. Use surgical text edits instead.
Trailing newline handling — PowerShell's Set-Content may not preserve trailing newlines. Use -NoNewline if the original file ends without a newline, or explicitly append "n"` if it should end with one.
This problem is not PowerShell-specific:
json.dump(): reformats indentation, key order, whitespaceJSON.stringify(): same issuesjson.MarshalIndent(): same issuesJSON.pretty_generate(): same issuesThe solution is universal: treat community-maintained JSON files as raw text, use regex or string search to find the insertion point, splice in the new content, and verify the diff shows only intended changes.
$filePath = "repositories.json"
$content = Get-Content $filePath -Raw
# Find the position of the last array element's closing brace
# assuming each entry ends with "}\n" before the final "]"
$pattern = '(.*?})(\s*\])' # Capture everything before final ], then the ]
# Construct the new entry (preserve the same indentation as surrounding entries)
$newEntry = @"
,
{
"author": "Mads Kristensen",
"name": "Gemstone Lights",
"category": "Lighting",
"location": "https://raw.githubusercontent.com/madskristensen/hubitat-drivers/main/repositories.json",
"description": "Control Gemstone Lights via local HTTP API"
}
"@
# Insert before the closing bracket
$newContent = $content -replace $pattern, "`$1$newEntry`$2"
# Write back without adding extra newlines
Set-Content -Path $filePath -Value $newContent -NoNewline
# Verify the diff shows only the intended 6-8 lines
git diff $filePath
import re
with open('repositories.json', 'r') as f:
content = f.read()
# Locate insertion point and inject new entry
pattern = r'(.*?})(\s*\])'
new_entry = ''',
{
"author": "Mads Kristensen",
"name": "Gemstone Lights",
...
}'''
new_content = re.sub(pattern, r'\1' + new_entry + r'\2', content, flags=re.DOTALL)
with open('repositories.json', 'w') as f:
f.write(new_content)
# Verify with `git diff`
Always use surgical text replacement for upstream community JSON files. Parse-and-regenerate workflows (ConvertFrom-Json/ConvertTo-Json, json.load/json.dump, JSON.parse/JSON.stringify) will reformat the file and break diff hygiene. Read as raw text, locate the insertion point with regex or string search, splice in the new content, and verify with git diff before pushing.