agentleFS
udaydeep1992udaydeep1992/pinescript-agents-antigravity/skills/pine-debugger/SKILL.md

pine-debugger

Skill0 starsChanged 41 days agoMITView on GitHub

Diagnoses and surgically fixes Pine Script compiler errors, runtime crashes, logical bugs, repainting issues, and unexpected trade behavior. Use when code fails to compile, produces warnings, hangs, or behaves incorrectly.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When diagnosing any issue:

    line 12
  2. Distinctive:

    Re-Check Surrounding Logic: Verify that types, historical offsets, array references, and variable declarations remain coherent after the …

    line 17
  3. Very specific:

    Fix: Use for...in or cache the boundary:

    line 55
  4. Distinctive:

    When runtime values need inspection without altering strategy execution:

    line 87

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Pine Script Debugger

Specialized in diagnosing and repairing Pine Script v6 scripts with minimal, targeted fixes.

Systematic Debugging Protocol

When diagnosing any issue:

  1. Reproduce & Identify: Analyze the exact compiler error message, line number, or symptom reported by the user.
  2. Isolate the Root Cause: Pinpoint the precise variable, line continuation, scope mismatch, or logic error causing the fault.
  3. Explain the Cause: Provide a concise explanation of why TradingView's compiler or execution model rejected the code.
  4. Propose the Smallest Correct Fix: Apply surgical changes to fix the error without gratuitously rewriting working parts of the script.
  5. Re-Check Surrounding Logic: Verify that types, historical offsets, array references, and variable declarations remain coherent after the edit.

Common Pine Script v6 Compiler Errors & Solutions

1. Cannot use 'plot' in local scope

  • Cause: Calling plot(), plotshape(), or plotcandle() inside an if, for, or function block.
  • Fix: Move plot() to global script scope and use ternary conditions:
    // ❌ Broken
    if buySignal
        plot(fastMA)
    
    // ✅ Fixed
    plot(buySignal ? fastMA : na, "Buy Signal MA", color=color.green)

2. Syntax error at input 'end of line without line continuation'

  • Cause: Breaking expressions across lines incorrectly, especially splitting ternary operators (? :) or indenting continuation lines with multiples of 4 spaces.
  • Fix:
    // ❌ Broken
    sig = condition ?
        "Buy" :
        "Sell"
    
    // ✅ Fixed
    sig = condition ? "Buy" : "Sell"
    
    // For boolean chains outside (), use 5 spaces (non-multiple of 4)
    valid = condA and
         condB and
         condC

3. Loop Freezes / Script Exceeds Maximum Execution Time

  • Cause: Traditional for i = 0 to array.size(arr) re-evaluating boundaries in v6 (March 2025 change) causing infinite loops if elements are pushed inside.
  • Fix: Use for...in or cache the boundary:
    // ✅ Fixed with for...in
    for [idx, item] in myCollection
        // Safe execution
    
    // ✅ Fixed with cached size
    total = array.size(myCollection)
    for i = 0 to total - 1
        // Safe execution

4. undeclared identifier / Variable Scope Shadowing

  • Cause: Assigning to a variable created inside an inner scope or using = instead of := for re-assignment.
  • Fix: Declare variable at the outer scope with var or varip, and use := for assignment:
    var float highestHigh = na
    if condition
        highestHigh := math.max(highestHigh, high)

5. request.security Repainting Warning

  • Cause: Missing lookahead=barmerge.lookahead_off or referencing current bar close of higher timeframe.
  • Fix:
    htfClose = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_off)

Interactive Debugging Tools (Non-Intrusive)

When runtime values need inspection without altering strategy execution:

1. Single-Bar Debug Label

if barstate.islast
    label.new(bar_index, high,
              str.format("Debug Info:\nClose: {0,number,#.##}\nRSI: {1,number,#.##}\nSignal: {2}",
                         close, rsiVal, signalBool),
              style=label.style_label_down, color=color.navy, textcolor=color.white)

2. Variable Monitor Table

var table dbg = table.new(position.top_right, 2, 4, bgcolor=color.new(color.black, 70))
if barstate.islast
    table.cell(dbg, 0, 0, "Var", text_color=color.white)
    table.cell(dbg, 1, 0, "Val", text_color=color.white)
    table.cell(dbg, 0, 1, "RSI", text_color=color.gray)
    table.cell(dbg, 1, 1, str.tostring(rsiVal, "#.##"), text_color=color.yellow)

Consult docs/pine-error-log.md for project-specific compiler logs and solutions.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.