Arcpy safe edits
Skill buildmoonshot/skillpacks/skills/gis/expert/arcpy-safe-edits
A beginner-to-expert curriculum of drop-in skills for Claude Code, Codex, and any coding agent. Copy-paste ready, tested, not a link farm.
npx -y skills add buildmoonshot/skillpacks --skill arcpy-safe-editsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when editing data in an Esri enterprise geodatabase (SDE) or any versioned, networked, or topology-participating data with ArcPy — updating, inserting, or deleting features. Makes the agent use edit sessions, respect versioning and locks, and avoid corrupting multiuser geodatabase data.
SKILL.md
2.3 KB, as published. Nobody here has run it
ArcPy Safe Edits
Editing an enterprise geodatabase is not editing a file. Versioning, locks, and related data make "just run an UpdateCursor" a way to corrupt production. Edit safely.
Use an edit session
- Wrap edits in
arcpy.da.Editor(workspace)withstartEditing()/startOperation(). An edit session is required for versioned data, and for data participating in topologies, geometric/utility networks, relationship classes, or attribute rules. - Choose the right mode:
startEditing(with_undo, multiuser_mode)—multiuser_mode=Truefor versioned SDE,Falsefor nonversioned. - On error,
abortOperation()/stopEditing(save_changes=False); onlystopEditing(True)after success. Wrap in try/except so a failure rolls back instead of leaving a half-applied edit.
Manage cursors and locks
- Use
arcpy.da.UpdateCursor/InsertCursorinside the edit session, always with awithblock (ordelthe cursor) so it releases its lock. A leaked cursor holds a lock that blocks every other editor. - Don't hold a schema lock longer than needed; ensure no ArcGIS Pro session or other process has the dataset open when you need exclusive access.
Respect versioning
- Edit the correct version, not
DEFAULTdirectly in a multiuser workflow. Understand the reconcile/post cycle; leave reconcile/post andCompressto the established workflow (often a DBA task), don't improvise them.
Respect data integrity
- Honor domains, subtypes, and attribute rules — writing an out-of-domain value or bypassing a rule corrupts data quietly.
- Test on a copy or a non-default version first. Never debug edit logic against production DEFAULT.
Why this matters
A naive cursor edit on versioned SDE can deadlock other editors, leave a half-applied transaction, or violate referential integrity across related classes — and the damage is multiuser and hard to undo. Edit sessions, scoped locks, and the right version turn risky writes into safe, atomic ones.