xiaohongshu
xiaohongshu
julia-evaluation
This skill should be used when the user asks to "run Julia code", "evaluate Julia", "use Julia", mentions "persistent Julia session", "TTFX", or wants to work with Julia for data analysis, scientific computing, or package development. Provides best practices for using the Julia REPL MCP tools eff...
Full skill instructions
This skill provides guidance for using the persistent Julia REPL via MCP tools. AgentREPL maintains a worker subprocess for code evaluation, eliminating the "Time to First X" (TTFX) startup penalty that normally occurs with each Julia invocation.
AgentREPL uses a distributed worker model (recommended):
reset kills the worker and spawns a fresh one (true hard reset)log_viewer tool to open a terminal showing output in real-timeTo see Julia output as it happens:
log_viewer(mode="auto") # Opens a terminal with live output
Or set JULIA_REPL_VIEWER=auto environment variable before starting.
Tmux mode is deprecated due to unfixable marker pollution issues. Use distributed mode (default) with log_viewer for visual output.
| Tool | Purpose |
|---|---|
eval | Evaluate Julia code with persistent state |
reset | Hard reset - kills worker, spawns fresh one (enables type redefinition) |
info | Get session info (version, project, variables, worker ID) |
pkg | Manage packages (add, rm, status, update, instantiate, resolve, test, develop, free) |
activate | Switch active project/environment |
log_viewer | Open a terminal window showing Julia output in real-time |
mode | (Deprecated) Switch between distributed and tmux modes |
The goal is to make Julia work feel like an interactive REPL session.
Always display code in a readable format before calling eval. The MCP permission prompt shows code as an escaped string which is difficult to read.
Running this Julia code:
```julia
A = [1 2 3; 4 5 6; 7 8 9]
det(A)
[then call eval]
### After Evaluation: Format Results Beautifully
Present results in REPL-style with proper formatting:
```julia
julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Matrix{Int64}:
1 2 3
4 5 6
7 8 9
julia> det(A)
0.0
This workflow gives users the best of both worlds: they can verify code before it runs, and see results in a beautiful, readable format afterward.
The first call to eval in a session may take several seconds due to:
Subsequent calls are fast because the worker process stays alive with compiled code in memory. This is the core value proposition of AgentREPL.
Variables, functions, and loaded packages persist across eval calls:
# First call
x = 42
f(n) = n^2
# Later call - x and f still exist
f(x) # Returns 1764
resetThe reset tool kills the worker process and spawns a fresh one. This means:
Use reset when:
After reset, packages need to be reloaded with using.
The activated environment persists across resets.
Julia best practice is to use project-specific environments. Use activate to switch environments:
activate(path=".") # Current directory
activate(path="/path/to/proj") # Specific project
activate(path="@v1.10") # Named shared environment
After activation, install dependencies:
pkg(action="instantiate")
The activated environment persists even across reset calls.
Use pkg for all package operations:
Adding packages:
pkg(action="add", packages="JSON, DataFrames, CSV")
Checking installed packages:
pkg(action="status")
Installing from Project.toml:
pkg(action="instantiate")
Running tests:
pkg(action="test") # Test current project
pkg(action="test", packages="MyPkg") # Test specific package
Development workflow (local packages):
pkg(action="develop", packages="./path/to/MyLocalPackage") # Use local code
pkg(action="free", packages="MyPackage") # Return to registry
After adding a package, load it:
using JSON
For running tests, use pkg(action="test"):
This is preferred over running tests via eval because it properly isolates the test environment.
When developing a local package alongside your project:
Put the package in develop mode:
pkg(action="develop", packages="./MyLocalPackage")
Make changes to the package source code
Test your changes:
pkg(action="test", packages="MyLocalPackage")
When done, return to registry version:
pkg(action="free", packages="MyLocalPackage")
The develop action accepts:
./ or ..//~Common issues and solutions:
| Error | Cause | Solution |
|---|---|---|
UndefVarError | Variable not defined | Re-run earlier code or check spelling |
MethodError | Wrong argument types | Check function signatures |
LoadError | Package not installed | Use pkg(action="add", packages="...") |
cannot redefine | Type redefinition | Use reset for a fresh worker |
StackOverflowError | Infinite recursion | Fix recursion, may need reset |
When first using Julia in a session, ask the user about their environment preference before running code:
"Before we start, which Julia environment should I use?
- Current directory - activate Project.toml in this folder (if it exists)
- Specific project - provide a path to a Julia project
- Default - use the global environment
This determines where packages are installed and what dependencies are available."
Based on their answer:
activate(path=".") then pkg(action="instantiate")activate(path="/their/path") then pkg(action="instantiate")For a typical Julia task:
activate + pkg(action="instantiate")evalpkg(action="test") to verify changesreset if types need redefining or state is corruptedMulti-line code blocks work naturally:
function fibonacci(n)
if n <= 1
return n
end
return fibonacci(n-1) + fibonacci(n-2)
end
[fibonacci(i) for i in 1:10]
CRITICAL: Always format Julia results in a readable REPL-style code block.
After calling eval, present the results to the user in a nicely formatted way that mimics the Julia REPL experience. This is especially important for:
Example - Good formatting:
julia> A = [1 3 4; 4 5 6; 2 0 3]
3×3 Matrix{Int64}:
1 3 4
4 5 6
2 0 3
julia> inv(A)
3×3 Matrix{Float64}:
-0.6 0.36 0.08
0.0 0.2 -0.4
0.4 -0.24 0.28
Example - Bad formatting (don't do this):
The result is
[1 3 4; 4 5 6; 2 0 3]and the inverse is[-0.6 0.36 0.08; 0.0 0.2 -0.4; 0.4 -0.24 0.28]
The REPL-style formatting:
julia> prompt with the commandBoth return values and printed output are captured from the eval tool. Format them beautifully as shown above.
Prefer direct bash commands when:
julia script.jlUse the MCP tools when:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience