Use when learning about selecting and using anchors for AnchorScope - provides practical strategies and decision trees for effective anchoring
Related skills: Core workflow?
/skill:anchorscope-core. Single-phase tasks?/skill:anchorscope-decomposer. For detailed technical spec, seeAnchorScope-tutorial.md.
When to use this skill:
Level 1 (Wide): Anchor the function/class/module (file-level uniqueness)
Level 2 (Narrow): Read the buffer, anchor specific pattern (buffer-level uniqueness)
Why this works:
Function/method signatures (highest)
def calculate_total(items: list) -> int:
fn main() {
public function render() {
Class definitions
class BillingService:
Unique configuration keys
"max_retries": 3,
APP_ENV = "production"
Character comments (if present)
// Production config
return result, pass, i += 1, }# File: processor.py
def process_orders():
for i in range(10):
print(f"Processing {i}")
def process_users():
for i in range(10):
print(f"User {i}")
Problem: for i in range(10): appears TWICE
Solution:
anchorscope read --file processor.py --anchor "def process_orders():"anchorscope read --true-id <level1_id> --anchor "for i in range(10):"
process_orders() buffer!# File: utils.py
def calculate_total(items):
total = 0
for item in items:
total += item
return total
def calculate_average(items):
total = 0
for item in items:
total += item
return total / len(items)
Problem: Similar patterns in both functions
Solution:
If your anchor appears multiple times, expand it by adding context:
| Original | Expanded |
|---|---|
for i in range(10): | def process():\n for i in range(10): |
return result | def calculate():\n total = 0\n for item in items:\n total += item\n return result |
} | def process():\n for i in range(10):\n print(i)\n} |
def process():
for i in range(10):
print(i)
def another():
for i in range(10):
print(i)
Fix: Include more context in Level 1
anchorscope read --file app.py --anchor $'def process():\n for i in range(10):'
# Wrong: Reusing stale True ID
anchorscope read --file file.py --anchor "fn foo()" # true_id = AAA
anchorscope read --true-id AAA --anchor "x = 1" # true_id = BBB
anchorscope write --true-id BBB --from-replacement # BBB deleted, AAA stale!
anchorscope read --true-id AAA --anchor "y = 2" # WRONG! AAA is stale!
Correct: Re-read from file
anchorscope read --file file.py --anchor "fn foo()" # true_id = AAA_NEW (fresh!)
--expected-hash must use the scope_hash from read (NOT file_hash!)| Situation | Approach |
|---|---|
| Simple one-time edit | Single-level anchoring |
| Multiple similar patterns | Multi-level anchoring |
| Team collaboration | Use labels with True IDs |
| Debugging issues | Use anchorscope paths to inspect buffers |
| Long workflows | Use labels instead of raw True IDs |
AnchorScope-tutorial.md (full CLI spec)/skill:anchorscope-core/skill:anchorscope-decomposer| Command | Purpose |
|---|---|
read --file <path> --anchor "<text>" | Anchor scope at file level |
read --true-id <id> --anchor "<text>" | Anchor scope within buffer |
label --name <name> --true-id <id> | Create human-readable alias |
paths --true-id <id> | Inspect buffer locations |
tree --file <path> | Visualize buffer structure |
--expected-hash