For a man performing iʿtikāf, remaining in the mosque is fundamental. The retreat is not an arrangement permitting unrestricted errands between a house and a market.
Hanafi commentaries further discuss the qualifications of a congregational mosque. The exact type of retreat and designated place must be established before it begins.