Use shell heredoc syntax as a workaround when write_file fails on complex TypeScript/JSX/code files with encoding or escaping issues
67
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./benchmarks/gdpval/skills/heredoc-file-write/SKILL.mdUse this pattern when:
write_file repeatedly fails with "unknown error" or similar messagesSwitch from write_file to run_shell using heredoc syntax with cat. The heredoc approach handles special characters, quotes, and complex content more reliably.
When write_file fails repeatedly on the same file:
Execute shell command with heredoc:
cat > /path/to/file.tsx << 'EOF'
// Your file content here
import React from 'react';
const Component = () => {
return <div>Hello</div>;
};
export default Component;
EOFUse quoted delimiter ('EOF' not EOF) to prevent variable expansion:
'EOF' = literal content (recommended for code files)EOF = allows variable expansion (use only if needed)Match delimiters exactly: Opening and closing EOF must be on their own lines with no leading/trailing whitespace
No escaping needed: Content between delimiters is taken literally when using quoted delimiter
After executing the heredoc command:
ls -la /path/to/file.tsxcat /path/to/file.tsx or head -20 /path/to/file.tsxcat > src/components/Button.tsx << 'EOF'
import React from 'react';
interface ButtonProps {
label: string;
onClick: () => void;
}
export const Button: React.FC<ButtonProps> = ({ label, onClick }) => {
return (
<button onClick={onClick} className="btn-primary">
{label}
</button>
);
};
EOFcat > tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"esModuleInterop": true
},
"include": ["src/**/*"]
}
EOFcat > deploy.sh << 'EOF'
#!/bin/bash
set -e
echo "Deploying..."
if [ "$ENV" = "production" ]; then
echo "Production deployment"
fi
EOFwrite_file for dynamic content generationProblem: File not created at expected path
pwdProblem: Content appears corrupted
'EOF') and closing delimiter has no trailing whitespaceProblem: Permission denied
c5a9c4b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.