Original Reddit post

I learned to code with COBOL, FORTRAN and MS-DOS BASIC years ago, and during lockdown I did several online courses on full stack web dev. So total noob. I’d never used “A.I.” past a few rounds with OpenArt.ai when it first came out, and zero rounds with any sort of ChatBot. Therefore when I heard of Claude Code I was very intrigued. Claude.ai and I had a few chats, and I was immediately impressed. Claude.ai reminds me of a Big Golden Lab who’s just so happy to see you and wants to bring you the bestest, biggest, stickiest stick it can find just as fast as possible! So I signed up with Claude Code. Well if Claude.ai is a Big Golden Lab, then Claude Code is a Big Derpy Alaskan Husky! Dear GODS it’s equal parts amazing code writing and blazing down dead ends like his tail is on fire. So I started researching how to better direct CC, which brings us to this post. What I’m doing currently is coding app scripts for my work in publishing. Unlike the very well understood programming languages like Python or C++, the ExtendScript engine is JavaScript-based (understood) that manipulates the Adobe DOM (Document Object Model) to create and/or manipulate aspects of a file. This is an area that even CC says he doesn’t know that well. After just shy of two months of trial and error this is my root level CLAUDE.md file:

CLAUDE.md
Session Protocols
"Let's begin" (New):
Brainstorm real goal + edge cases → Create folder → copy
PLAN.md
template → populate (incl. DOM Research Table) →
code --new-window <folder>/PLAN.md
→
STOP
.
"Let's begin" (Existing):
Load folder +
PLAN.md
→
code --new-window <folder>/PLAN.md
→ brief [Step | Blocker | Next].
"Let's wrap":
Sync
PLAN.md
→ commit per GIT rules → push to GitHub.
Immutable:
00_System/01_Templates/
,
zz_Reference/
,
zzz_Archive/
.
Workflow Gates
BRAINSTORM:
Real goal + edge cases + DOM Research Table (docs/AI/web) before any code or probes.
PLAN:
name | summary | rationale →
PLAN.md
.
GATE.
LEARN:
Research → write all probes at once → run batch in target app → record learnings.
GATE.
CODE:
1 function at a time. ES3 only. Explain changes.
TEST:
Production testing in target app. Fail = Revert to Step 2.
Context Map
Git Rules:
.claude/rules/git.md
ExtendScript (General):
.claude/rules/extendscript.md
App Specifics:
Located in subfolder
CLAUDE.md
(InDesign, Illustrator, etc.)
Folder Map
// A structure so CC doesn't have to BASH his way round trying to find stuff. ```
This tightly structures how we develop scripts and what CC is allowed to during coding sessions. For a brief time I tried implementing the Karpathy Heuristics that hit this forum a few weeks ago, like “Visualize your logic…” but all that did was send CC into 20+ minute loops of nothing. DO NOT recommend!
As you can also see the system in modular, where /rules live somewhere else instead of in the root CLAUDE.md file (us Pro plan users need to be as token-efficient as possible, so only what’s needed gets loaded).
To show you how this works, here’s my prompt from yesterday about how to get ExtendScript output directly into CC CLI without me having to constantly copy & paste:
``` Let's begin here 03_Dev-Scripting/01_Claude-Code/Debug-Log (new folder) with a test. I've been informed on the internet that we can have the ExtendScript write to a log file and that you can then monitor this log file for changes and read back the script output directly.
[…] logToClaude(msg) [redacted] […] logToClaude;
We'd need to conform that path information to my systems, but can this even work? ```
Note:
I’ve had to trim out the code to avoid reddit filters.
Turns out yes you can! From that prompt here’s CC’s output:
PLAN: ExtendScript → File Log → Claude Monitor
Status:
🟡 Awaiting GATE 1 Sign-off
Karpathy Check:
[Simpler? Yes/No] | [Surgical? Yes/No]
0. Brainstorm & Research (Pre-GATE 1)
Real Goal:
Replace ESTK console (
$.writeln
) as the debug output channel with a file that Claude Code can tail in real time — enabling live script output in this session without needing ESTK open.
Edge Cases to Consider:
~
path shorthand may not expand in ExtendScript
File()
— use absolute path.
$.writeln
reassignment is host-dependent and may silently fail; safer to call
logToClaude()
directly.
Log file grows unboundedly — needs a clear/reset step at script start (open "w" once, then switch to "a").
Two simultaneously running scripts could interleave lines (unlikely for single-user debug use, noted).
tail -f
must be started before the script runs, or lines written before monitor attaches are missed (use
tail -n 0 -f
to ignore pre-existing content).
File locking: macOS APFS handles concurrent read/write safely for append — no special handling needed.
DOM Research Table
1. Summary | Rationale (GATE 1: PLAN)
Goal:
Prove that an ExtendScript helper (
logToClaude
) can append to a known file path, and that Claude Code's Monitor tool can tail that file and surface each line as a live notification.
Value:
Eliminates dependency on ESTK for debug output. Lets Claude Code read script results directly during a session — closing the loop between script execution and AI interpretation.
Success Criteria:
Running a probe in any Adobe host app causes its
$.writeln
-style output to appear in Claude Code's terminal within ~1 second, without ESTK.
2. Technical Strategy (GATE 1: PLAN)
Host/Engine:
InDesign (primary test), then Illustrator — ES3
Log File Path:
/Users/dar-mit/Documents/extendscript_log.txt
Monitor Command:
tail -n 0 -f /Users/dar-mit/Documents/extendscript_log.txt
Document State Contract:
None — standalone utility, no open document required.
DOM Map:
File("/Users/dar-mit/Documents/extendscript_log.txt")
— file handle
file.open("w")
on init to clear;
file.open("a")
per write call
Folder.userData
— resolves to
/Users/dar-mit
(to be confirmed via probe)
Confidence:
likely | Source: ExtendScript docs + community examples
3. Risks & Probes (GATE 2: LEARN)
Risk 1:
~
path does not expand → absolute path required.
Risk 2:
$.writeln
reassignment silently ignored → call
logToClaude()
directly.
Risk 3:
Append mode not supported or write fails silently → probe must assert return value.
Risk 4:
Folder.userData
resolves to unexpected path on this system.
Probe Batch
Probe-01_FileWrite-Append_IND.jsx
→ Confirm absolute path + open("a") + writeln works; log
Folder.userData
value.
Probe-02_WritelnOverride_IND.jsx
→ Attempt
$.writeln = logToClaude
reassignment; call
$.writeln("test")
; verify file receives the line (vs. only ESTK console).
Probe-03_ClearAndAppend_IND.jsx
→ Open "w" to clear file, then open "a" to append — confirm truncation works on first run.
Learnings (populated after batch run)
4. Architecture (GATE 3: CODE)
logToClaude(msg)
: Appends one line to the log file and closes immediately.
initLog()
: Opens file in "w" mode once to clear it at script start.
Optional:
$.writeln = logToClaude
— only if Probe 02 confirms it works.
Implementation Steps
[ ] Write Probe 01 — file write +
Folder.userData
[ ] Write Probe 02 —
$.writeln
override test
[ ] Write Probe 03 — clear + append cycle
[ ] Start
tail -n 0 -f
monitor in Claude Code session
[ ] Run probe batch in InDesign; record Learnings table
[ ] If confirmed: write final
logToClaude
helper as a reusable include
[ ] Commit
5. Changelog
v1.0: Initializing Spec-Driven Plan.
From this point we just work through the plan, step-by-step, and the CLAUDE.md file carefully guides that Big Derpy Husky to minimize fully exploring dead ends, changing code outside of the problem we’re working on, and other such helpful things he was doing before.
Anyways I hope this helps out some new coders who may find that CC doesn’t quite act the way they think an A.I. should.
Since I’m new if anyone sees any issues or have any improvements I’d be very appreciative to hear them.
Oh, PRO TIP: If you find that CC has gone off in an unexpected manner ASK CC why? I found this out with those Karpathy bits, when CC was at the 17 minutes mark after being asked to update a rotational formula. Turns out he was re-driving a known formula to see if he could get it past the “95% confidence” threshold.
Best, dar-mit
submitted by
/u/dar-mit

Originally posted by u/dar-mit on r/ClaudeCode