pemsley/coot/best-practices
Claude Code and agent skill by pemsley/coot
- community
Checking that the SKILL.md file is still in the repository.
Best Practices for using Coot MCP
Install
npx vskill@latest install pemsley/coot/best-practicesSKILL.md
Coot Python API Best Practices
Overview
This skill provides best practices for interacting with Coot's Python API through the MCP server. Following these guidelines ensures optimal performance, correct usage, and reliable results.
Python Execution in Coot MCP
CRITICAL: Understanding run_python() vs run_python_multiline()
Coot MCP provides two tools for executing Python code with different capabilities and limitations:
run_python() - Simple Expressions Only
Use for single expressions that return a value. Cannot handle imports or semicolons.
Rule: Use run_python() ONLY for:
- Single expressions with no semicolons
- No import statements
- Direct function calls that return a value
run_python_multiline() - Everything Else
Use for any code requiring imports, multiple statements, or function definitions:
Rule: Use run_python_multiline() for:
- Any import statements
- Multiple statements (even without imports)
- Function definitions
- Loops and control flow
- Anything with complexity
Key Differences Table
| Feature | run_python() | run_python_multiline() | |
|---|---|---|---|
| Import statements | ❌ Fails | ✓ Works | |
| Semicolons | ❌ Fails | ✓ Works | |
| Multiple lines | ❌ Fails | ✓ Works | |
| Function defs | ❌ Fails | ✓ Works | |
| Simple expressions | ✓ Works | ✓ Works | |
| Return value | Returns value | Returns None (use print) |
Common Mistake Pattern
When in Doubt
Use `run_python_multiline()` - it handles everything run_python() can do, plus more. The only downside is that it returns None rather than a value, so use print() to see output.
File Writing from Coot Python
CRITICAL: When writing files from Coot's Python, ALWAYS write to the current directory without specifying a path.
The Problem
Coot's Python interpreter runs in a specific working directory (/Users/pemsley/Projects/coot/git/coot-main/build/src), which is different from both:
- The bash working directory (
/home/claude) - Mounted shared directories (
/mnt/user-data/...)
Attempting to write to an explicit path that doesn't exist in Coot's context will cause FileNotFoundError.
✅ CORRECT: Write to Current Directory
❌ INCORRECT: Don't Specify Paths
Pattern for Working with Files
Why This Works
Coot's Python interpreter automatically uses its working directory. By omitting paths:
- Files are created in a location that exists
- No permission issues
- No cross-filesystem problems
- Simple and reliable
User Talk
When the user says "here" in an ambiguous way, they typically mean "applying the relevant function to this residue (or atom or chain)" - i.e. the residue (or atom or chain) at the centre of the screen.
Getting Files to the User [warning: this needs review!]
After creating files in Coot's working directory, use bash tools to copy them to /mnt/user-data/outputs where the user can access them, or share results via print output.
Startup Procedure
CRITICAL: On every "Coot Mode" start, before doing anything else:
- Read the
/mnt/skills/user/coot-essential-api/SKILL.mdfile - Extract all function names mentioned in that file
- Call
get_function_descriptions()with the complete list of function names - This loads the essential API documentation into context, providing immediate access to the ~25 core functions needed for typical validation and model-building workflows
Why `get_function_descriptions` and not `search_coot_functions`? search_coot_functions can return sparse or incomplete docs for some functions. get_function_descriptions retrieves the full docstring including return value structure. Always prefer get_function_descriptions for known function names — use search_coot_functions only when you don't know the function name yet.
Example:
Only after completing this startup should you proceed with the user's task.
Critical Rule: Prefer C++ Functions Over Python Wrappers
ALWAYS use `coot.*_py()` functions directly instead of `coot_utils.*` equivalents when they are simple passthroughs.
Why?
- Performance: C++ functions are significantly faster (no Python overhead)
- Import requirements:
cootis auto-imported,coot_utilsrequires explicit import - Simplicity: Direct access to the core API without unnecessary abstraction layers
- Reliability: Fewer layers means fewer potential points of failure
Module Import Requirements
Auto-imported
- `coot` - The core C++/SWIG binding is automatically available
- No import statement needed
Requires explicit import
- `coot_utils` - Python utility library built on top of
coot - Must execute:
import coot_utilsbefore using any of its functions
Example of the problem:
But in this case (for chain-ids), this is preferred:
Function Naming Conventions
C++ Functions (SWIG bindings)
- End with
_py()suffix - Examples:
closest_atom_simple_py(),is_valid_model_molecule(),chain_id_py() - These are the core functions - prefer these
Python Wrapper Functions
- No
_py()suffix - Examples:
closest_atom(),closest_atom_simple(),chain_ids() - Only use when they provide genuine convenience
Specific Function Guidance
✅ CORRECT: Getting Closest Atom
❌ INCORRECT: Don't use coot_utils for simple passthroughs
✅ CORRECT: When to use coot_utils
Use coot_utils functions when they provide genuine convenience or abstraction:
Checking Molecule Validity
Getting Molecule Information
MMDB Atom Selection Syntax
When using functions like new_molecule_by_atom_selection(), superpose_with_atom_selection(), or get_hydrogen_bonds_py(), use MMDB CID (Coordinate ID) strings to specify which atoms to include.
Format
or for residue-name-based selection:
Components
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingmcp/docs/skills/best-practices/SKILL.md
Popularity
- Repository stars
- 160
- Repository forks
- 60
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pemsley/coot/best-practices)