# Fallback File Creation

> Fallback pattern for reliable file creation when code execution tools fail

- **Type:** Skill
- **Install:** `agentstack add skill-hkuds-openspace-fallback-file-creation`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [HKUDS](https://agentstack.voostack.com/s/hkuds)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [HKUDS](https://github.com/HKUDS)
- **Source:** https://github.com/HKUDS/OpenSpace/tree/main/gdpval_bench/skills/fallback-file-creation

## Install

```sh
agentstack add skill-hkuds-openspace-fallback-file-creation
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Fallback File Creation Workflow

Use this skill when `execute_code_sandbox` or `shell_agent` fails repeatedly for file creation tasks. This pattern provides a manual but reliable approach to create and verify files.

## When to Use

- Code execution tools fail after multiple retries
- You need to create specific file formats (PDF, DOCX, etc.)
- Direct shell commands are more reliable than generated scripts
- You need explicit verification of file outputs

## Step-by-Step Instructions

### Step 1: Verify Working Directory

Before any file operations, confirm your current location:

```bash
pwd
ls -la
```

This ensures you're creating files in the correct workspace directory.

### Step 2: Create Scripts via Heredoc

Use shell heredocs to create scripts with properly escaped syntax:

```bash
cat > /path/to/script.sh  /workspace/create_pdf.sh  /workspace/create_docx.sh << 'EOF'
#!/bin/bash
cd /workspace
pandoc -f markdown -t docx action_tracker.md -o action_tracker.docx
EOF

# Step 3: Execute
chmod +x /workspace/create_docx.sh
/workspace/create_docx.sh

# Step 4: Verify
ls -lh /workspace/action_tracker.docx
unzip -l /workspace/action_tracker.docx | head -20
```

## Best Practices

1. **Always verify before and after** - Check directory state before starting and after completion
2. **Use absolute or explicit paths** - Avoid ambiguity in file locations
3. **Quote heredoc delimiters** - Use `'EOF'` to prevent unwanted variable expansion
4. **Make scripts executable** - Always `chmod +x` before running
5. **Inspect file metadata** - Use format-specific tools (pdfinfo, unzip -l, file) to verify content
6. **Keep scripts simple** - Each script should do one thing well
7. **Clean up temporary files** - Remove intermediate files after successful completion

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Script not found | Use full path: `/workspace/script.sh` |
| Permission denied | Run `chmod +x script.sh` |
| File not created | Check script output, verify working directory in script |
| Wrong file format | Verify conversion tool supports target format |
| Corrupted output | Re-run with verbose mode, check intermediate files |

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [HKUDS](https://github.com/HKUDS)
- **Source:** [HKUDS/OpenSpace](https://github.com/HKUDS/OpenSpace)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-hkuds-openspace-fallback-file-creation
- Seller: https://agentstack.voostack.com/s/hkuds
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
