Skip to content
Back to skills

Arcpy Safe Edits

ASecurity

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.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 7, 2026
ai-agentsdatabase

Works with

  • cursor

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add buildmoonshot/skillpacks --skill arcpy-safe-edits --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Arcpy Safe Edits?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Arcpy Safe Edits
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/buildmoonshot-arcpy-safe-edits/badge)](https://www.skillsdirectory.com/skills/buildmoonshot-arcpy-safe-edits)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: arcpy-safe-edits
description: 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.
---

# 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)` with `startEditing()` / `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=True` for versioned SDE, `False` for nonversioned.
- On error, `abortOperation()` / `stopEditing(save_changes=False)`; only `stopEditing(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` / `InsertCursor` **inside** the edit session, always with a `with` block (or `del` the 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 `DEFAULT` directly in a multiuser workflow. Understand the reconcile/post cycle; leave reconcile/post and `Compress` to 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.

Files in this skill

  • README.md1.6 KB
  • SKILL.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…